araphon1
Junior Member
Posts: 5
Threads: 2
Joined: Mar 2012
Reputation:
0
|
New Problem: SetEntityPlayerLookAtCallback
I dont want the grunt to move away until I look at him. This is what Frictional Games say about this callback:
void SetEntityPlayerLookAtCallback(string& asName, string& asCallback, bool abRemoveWhenLookedAt);
Calls a function when the player looks at a certain entity.
Callback syntax: void MyFunc(string &in asEntity, int alState)
alState: 1 = looking, -1 = not looking
asName - internal name
asCallback - function to call
abRemoveWhenLookedAt - determines whether the callback should be removed when the player looked at the entity
So, what I did was this:
void OnStart()
{
SetEntityPlayerLookAtCallback("Entity", "Function", true);
}
This means that when I look at "Entity" the script calls "Function" and then removes the callback, right?
Now here's the function:
void Function(string &in asEntity, 1)
{
AddEnemyPatrolNode("Entity","PathNodeArea_4",1,"idle");
AddEnemyPatrolNode("Entity","PathNodeArea_5",0,"idle");
}
Doesnt work. My error message: Expected Data Type (pointed at the ,1 in void Funtion)
So I figured, ok, I need to declare data type as Integer:
void Function(string &in asEntity,int 1)
Nope. THen I got the error "Expected ) or ," pointing right after the "int". So I added a ,
void Function(string &in asEntity,int, 1)
After which I get the data error again.
(This post was last modified: 03-14-2012, 02:17 PM by araphon1.)
|
|
03-14-2012, 02:15 PM |
|
Strembitsky
Senior Member
Posts: 254
Threads: 37
Joined: Feb 2012
Reputation:
3
|
RE: New Problem: SetEntityPlayerLookAtCallback
void Function(string &in asEntity, int 1)
I noticed you didn't have a space between asEntity and int. Maybe that's the problem?
The Nightmares v1.0 - Dreadful Fires WIP
|
|
03-14-2012, 02:21 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
RE: New Problem: SetEntityPlayerLookAtCallback
StartPlayerLookAt and StopPlayerLookAt();is the code you are looking for
StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);
Forces the player to look at a certain entity until StopPlayerLookAt is used.
asEntityName - the entity to look at
afSpeedMul - how fast should the player look at the entity
afMaxSpeed - maximum speed allowed
asAtTargetCallback - function to call when player looks at target
|
|
03-14-2012, 02:21 PM |
|
araphon1
Junior Member
Posts: 5
Threads: 2
Joined: Mar 2012
Reputation:
0
|
RE: New Problem: SetEntityPlayerLookAtCallback
(03-14-2012, 02:21 PM)SilentStriker Wrote: StartPlayerLookAt and StopPlayerLookAt();is the code you are looking for
StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);
Forces the player to look at a certain entity until StopPlayerLookAt is used.
asEntityName - the entity to look at
afSpeedMul - how fast should the player look at the entity
afMaxSpeed - maximum speed allowed
asAtTargetCallback - function to call when player looks at target Actually, no, thats not what im looking for. Im looking for a script that checks "Hey, IS the player, by free will, looking at this entity?" "Yes, he is." "OK, then lets make that grunt move, since the player IS looking at him."
Quote:
I noticed you didn't have a space between asEntity and int. Maybe that's the problem?
Nope, already tried that one No matter how I place spaces etc, it just doesnt work. And in all other int alState I have come across, you just put down an integer, you dont have to declare data type. I've done that with loads of collide callbacks etc, no problem. But in this particular piece of code, it just feels like acting up.
(This post was last modified: 03-14-2012, 02:32 PM by araphon1.)
|
|
03-14-2012, 02:25 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
RE: New Problem: SetEntityPlayerLookAtCallback
try this:
void Function(string &in asEntity, int alState)
{
if(alState == 1){
AddEnemyPatrolNode("Entity","PathNodeArea_4",1,"idle");
AddEnemyPatrolNode("Entity","PathNodeArea_5",0,"idle");
}
}
|
|
03-14-2012, 02:39 PM |
|
araphon1
Junior Member
Posts: 5
Threads: 2
Joined: Mar 2012
Reputation:
0
|
RE: New Problem: SetEntityPlayerLookAtCallback
(03-14-2012, 02:39 PM)SilentStriker Wrote: try this:
void Function(string &in asEntity, int alState)
{
if(alState == 1){
AddEnemyPatrolNode("Entity","PathNodeArea_4",1,"idle");
AddEnemyPatrolNode("Entity","PathNodeArea_5",0,"idle");
}
} I tried it, with additions:
void Function(string &in asEntity, int alState)
{
if((alState == 1) && (GetLocalVarInt("MonsterSpawned_1") == 1))
{
AddEnemyPatrolNode("Entity","PathNodeArea_4",1,"idle");
AddEnemyPatrolNode("Entity","PathNodeArea_5",0,"idle");
}
}
Now the script runs, but not as expected. I look at the grunt, but he doesn't move. My thought: How does the if know which alState to look at? I have quite a few already see.
|
|
03-14-2012, 02:56 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
RE: New Problem: SetEntityPlayerLookAtCallback
I would guess the If uses the functions alState
it should look like this
void Function(string &in asEntity, int alState)
{
if(alState == 1 && GetLocalVarInt("MonsterSpawned_1") == 1)
{
AddEnemyPatrolNode("Entity","PathNodeArea_4",1,"idle");
AddEnemyPatrolNode("Entity","PathNodeArea_5",0,"idle");
}
}
(This post was last modified: 03-14-2012, 03:07 PM by SilentStriker.)
|
|
03-14-2012, 03:01 PM |
|
araphon1
Junior Member
Posts: 5
Threads: 2
Joined: Mar 2012
Reputation:
0
|
RE: New Problem: SetEntityPlayerLookAtCallback
(03-14-2012, 03:01 PM)SilentStriker Wrote: I would guess the If uses the functions alState
it should look like this
void Function(string &in asEntity, int alState)
{
if(alState == 1 && GetLocalVarInt("MonsterSpawned_1") == 1)
{
AddEnemyPatrolNode("Entity","PathNodeArea_4",1,"idle");
AddEnemyPatrolNode("Entity","PathNodeArea_5",0,"idle");
}
} Well, I tried that, but it still didn't work. The script doesnt seem to realize I am looking at the grunt, because he just stays there until I get aggo from staring at him.
|
|
03-14-2012, 03:18 PM |
|
|