Frictional Games Forum (read-only)
Script not working? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Script not working? (/thread-15667.html)



Script not working? - cheztheguy - 05-28-2012

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?


RE: Script not working? - Putmalk - 05-28-2012

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. >.>


Re: Script not working? - cheztheguy - 05-28-2012

Thank you, switching between the two worked.

And haha, sorry, I changed the 30 to 10.


RE: Script not working? - Putmalk - 05-28-2012

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.