Frictional Games Forum (read-only)

Full Version: Script not working?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone...
it seems that I tried to put a script area but when the player collides into it, the script doesn't show up.

Here is my script

Spoiler below!
void OnStart()
{
SetEnemyDisableTriggers("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", false);
SetMoveObjectState("Gruntwalkdoor", 1.0f);
AddEntityCollideCallback("walkgrunt", "Player", "WalkGruntDoor", false, 0);
}

void WalkGruntDoor(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_2", true);
SetEnemyDisableTriggers("servant_grunt_2", true);
StartPlayerLookAt("servant_grunt_2", 7.0f, 50.0f, "");
StopPlayerLookAt();
GiveSanityDamage(30.0f, true);
AddEntityCollideCallback("servant_grunt_2", "DoorGruntGone", "GruntGone", false, 0);
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_1", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_2", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_3", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_4", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_5", 0.0f, "");
}

void GruntGone(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_2", false);
SetMoveObjectStateExt("Gruntwalkdoor", 0, 7.0f, 50.0f, 0.0f, true);
}


Here are some screenshots of the editor:
Spoiler below!

[Image: walkgruntscript.png]

[Image: walkgruntscript2ug.png]

[Image: walkgruntscript3.png]



What am I doing wrong?
Switch "Player" and "walkgrunt". Player should always be asParent

And I'm sorry, but SanityDamage minus 30? Make that ten or something, 30 is 1/3 of your sanity, which should not happen from a monster spawn. >.>
Thank you, switching between the two worked.

And haha, sorry, I changed the 30 to 10.
Allow me to specify one thing.

asParent shouldn't always be Player, it should always be the entity which enters the area. asChild is always the secondary entity.

Therefore, the player enters the area, so Player should be asParent and area should be asChild. This can also apply to chairs hitting walls, etc. It's best if asChild was a stationary object, as asChild cannot initiate the collision callback, but asParent as to.