Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
asAtTargetCallback???
reper1210 Offline
Junior Member

Posts: 18
Threads: 7
Joined: Mar 2012
Reputation: 0
#1
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
Find
str4wberrypanic Offline
Member

Posts: 241
Threads: 24
Joined: Jul 2012
Reputation: 8
#2
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.

(This post was last modified: 01-16-2013, 04:00 AM by str4wberrypanic.)
01-16-2013, 04:00 AM
Find
reper1210 Offline
Junior Member

Posts: 18
Threads: 7
Joined: Mar 2012
Reputation: 0
#3
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
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#4
RE: asAtTargetCallback???

PHP Code: (Select All)
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"2020"");   // 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 itemstring &in entity)
{
SetLevelDoorLocked(entityfalse); 

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:
PHP Code: (Select All)
StartPlayerLookAt("mansion_door_1"2020""); 
You can modify the values (20, 20 in this case) to different values. The lower the number, the slower the player will look.

In Ruins [WIP]
(This post was last modified: 01-16-2013, 05:42 AM by NaxEla.)
01-16-2013, 05:39 AM
Find
reper1210 Offline
Junior Member

Posts: 18
Threads: 7
Joined: Mar 2012
Reputation: 0
#5
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
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#6
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:

PHP Code: (Select All)
void AddTimer(stringasNamefloat afTimestringasFunction); 
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:
PHP Code: (Select All)
AddTimer(""3"StopLookingFunc"); // you can change '3' to whatever number you like 
Then make a new function called "StopLookingFunc" that looks like this:
PHP Code: (Select All)
void StopLookingFunc(string &in asTimer)
{
    
StopPlayerLookAt();


In Ruins [WIP]
01-16-2013, 06:16 AM
Find




Users browsing this thread: 2 Guest(s)