reper1210
Junior Member
Posts: 18
Threads: 7
Joined: Mar 2012
Reputation:
0
|
asAtTargetCallback???
what do i write for this?
asAtTargetCallback - function to call when player looks at target
this is the code i need to write it in.
void StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);
void StopPlayerLookAt();
and this is what i have for it so far.
StartPlayerLookAt(string& mansion_door_1, 20, 20, string& asAtTargetCallback);
StopPlayerLookAt(3);
|
|
01-16-2013, 03:51 AM |
|
str4wberrypanic
Member
Posts: 241
Threads: 24
Joined: Jul 2012
Reputation:
8
|
RE: asAtTargetCallback???
AtTargetCallback is a function that happens when the player looks at the entity or area you want him to look. Anyway, if you don't want to use this, just leave this way:
StartPlayerLookAt(string& mansion_door_1, 20, 20, "");
And i think you will need to use a timer in this script.
|
|
01-16-2013, 04:00 AM |
|
reper1210
Junior Member
Posts: 18
Threads: 7
Joined: Mar 2012
Reputation:
0
|
RE: asAtTargetCallback???
(01-16-2013, 04:00 AM)str4wberrypanic Wrote: AtTargetCallback is a function that happens when the player looks at the entity or area you want him to look. Anyway, if you don't want to use this, just leave this way:
StartPlayerLookAt(string& mansion_door_1, 20, 20, "");
And i think you will need to use a timer in this script.
it crashed my game when i entered that in. game worked fine before so can i put the code in like this?
void OnStart()
{
GiveItemFromFile("lantern", "lantern.ent");
SetEntityPlayerInteractCallback("key_laboratory_1", "ActivateMonster", true);
AddUseItemCallback("OpenDoor", "key_laboratory_1", "level_hub_1", "UnlockLevelDoor", true);
}
void OnEnter()
{
}
void OnLeave()
{
}
void ActivateMonster(string &in item)
{
StartPlayerLookAt(string& mansion_door_1, 20, 20, "");
StopPlayerLookAt(3);
SetEntityActive("servant_brute_1", true);
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 0, "Idle");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_2", 0, "Idle");
}
void UnlockLevelDoor(string &in item, string &in entity)
{
SetLevelDoorLocked(entity, false);
|
|
01-16-2013, 04:59 AM |
|
NaxEla
Senior Member
Posts: 415
Threads: 5
Joined: Dec 2012
Reputation:
28
|
RE: asAtTargetCallback???
void OnStart() { GiveItemFromFile("lantern", "lantern.ent"); SetEntityPlayerInteractCallback("key_laboratory_1", "ActivateMonster", true); AddUseItemCallback("OpenDoor", "key_laboratory_1", "level_hub_1", "UnlockLevelDoor", true); }
void OnEnter() {
}
void OnLeave() {
}
void ActivateMonster(string &in item) { StartPlayerLookAt("mansion_door_1", 20, 20, ""); // changed this line StopPlayerLookAt(); // changed this line also SetEntityActive("servant_brute_1", true); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 0, "Idle"); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_2", 0, "Idle"); }
void UnlockLevelDoor(string &in item, string &in entity) { SetLevelDoorLocked(entity, false);
The way your script is set up right now, the player will look at the door, then instantly stop looking at it (the player's eyes may not even make it to the door). I would suggest adding a timer so that the player will stop looking after a certain amount of time.
One more thing. In this line:
StartPlayerLookAt("mansion_door_1", 20, 20, "");
You can modify the values (20, 20 in this case) to different values. The lower the number, the slower the player will look.
(This post was last modified: 01-16-2013, 05:42 AM by NaxEla.)
|
|
01-16-2013, 05:39 AM |
|
reper1210
Junior Member
Posts: 18
Threads: 7
Joined: Mar 2012
Reputation:
0
|
RE: asAtTargetCallback???
thanks for the help, it didn't crash my game this time but i guess i do need a timer. how would that go into my script? and where?
|
|
01-16-2013, 06:00 AM |
|
NaxEla
Senior Member
Posts: 415
Threads: 5
Joined: Dec 2012
Reputation:
28
|
RE: asAtTargetCallback???
(01-16-2013, 06:00 AM)reper1210 Wrote: thanks for the help, it didn't crash my game this time but i guess i do need a timer. how would that go into my script? and where?
Taken from the wiki:
void AddTimer(string& asName, float afTime, string& asFunction);
Creates a timer which calls a function when it expires.
Callback syntax: void MyFunc(string &in asTimer)
asName - the name of the timer
afTime - time in seconds
asFunction - the function to call
So you would put this after the StartPlayerLookAt line:
AddTimer("", 3, "StopLookingFunc"); // you can change '3' to whatever number you like
Then make a new function called "StopLookingFunc" that looks like this:
void StopLookingFunc(string &in asTimer) { StopPlayerLookAt(); }
|
|
01-16-2013, 06:16 AM |
|
|