Frictional Games Forum (read-only)
Monster script - 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: Monster script (/thread-19284.html)

Pages: 1 2


Monster script - giacomo9 - 11-19-2012

I've got a situation: on floor lays a key. When player pick up this key, a monster appears behind the closed door. What script I must use (and where put it), when I want to monster break the door after spawn and chase the player? Here's a full script of my custom story (bold scripts is the "monster" and "pick up a key" scripts, of course) Btw. sorry for mistakes, my English is not very good I think Big Grin

////////////////////////////
// Run when starting map
void OnStart()
{
AddUseItemCallback("", "basementkey_1", "basement_1", "KeyOnDoor", true);
AddEntityCollideCallback("Player", "tp_1", "DeadOne", true, 1);
AddEntityCollideCallback("Player", "tp_2", "ColinBody", true, 1);
SetEntityCallbackFunc("corridorkey", "OnPickup");
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("basement_1", false, true);
PlaySoundAtEntity("", "unlock_door", "basement_1", 0, false);
}




void DeadOne(string &in asParent, string &in asChild, int alStates)
{
SetEntityActive("GhostOne", true);
AddPropForce("GhostOne", 0, 0, -100000, "world");
PlaySoundAtEntity("", "24_iron_maiden.snt", "GhostOne", 0, false);
}




void ColinBody(string&in asParent, string &in asChild, int alStates)
{
SetEntityActive("ColinBody", true);
AddPropForce("ColinBody", 0, 0, 1000000, "world");
PlaySoundAtEntity("", "24_burn.snt", "ColinBody", 0, false);
}




void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("stevie_1", true);
}



RE: Monster script - Rowzter - 11-19-2012

Edit: Use this instead:

void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("stevie_1", true);
ShowEnemyPlayerPosition("stevie_1");
}


RE: Monster script - giacomo9 - 11-19-2012

Thank You very much, it works Smile
I have another question - I must use a script, to make enemy disappeared when player hiding in wardrobe? When monster breaks the door, he didn't want to disappear, when I hide. What should I do?


RE: Monster script - Rowzter - 11-19-2012

(11-19-2012, 11:13 PM)giacomo9 Wrote: Thank You very much, it works Smile
I have another question - I must use a script, to make enemy disappeared when player hiding in wardrobe? When monster breaks the door, he didn't want to disappear, when I hide. What should I do?
You could use pathnode that leads him in the room and make pathnodes for him to walk around with, then use moore pathnodes to send him out of the room and then a pathnode inside a scriptarea that will make him disapear

Like this:

AddEntityCollideCallback("MONSTERNAME", "AREA", "FUNCNAME", true, 1);



void FUNCNAME(string &in asParent, string &in asChild, int alState)
{
FadeEnemyToSmoke("MONSTERNAME", true);
}

the last pathnode the monster walks to should be inside AREA and then he will despawn


See if it works


RE: Monster script - liquiddr3amz - 11-23-2012

could someone explain what i did wrong :/ i am new to scripting


void ActivateMonster(string &in item)
{
SetEntityActive("servant_grunt_1",true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
}

AddEntityCollideCallback("servant_grunt_1", "ScriptArea_1", "FUNCNAME", true, 1);
void FUNCNAME(string &in asParent, string &in asChild, int alState)
{
FadeEnemyToSmoke("servant_grun_1", true);
}

i get a script error saying "main (29,25) : ERR expected identifer"


RE: Monster script - The chaser - 11-23-2012

AddEntityCollideCallback("servant_grunt_1", "ScriptArea_1", "FUNCNAME", true, 1);



This should go to your void OnStart().


RE: Monster script - liquiddr3amz - 11-23-2012

void OnStart()
{
AddEntityCollideCallback("servant_grunt_1", "ScriptArea_1", "FUNCNAME", true, 1);
}

void OnEnter()
{

}

void OnLeave()
{

}

void ActivateMonster(string &in item)
{
SetEntityActive("servant_grunt_1",true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
}


void FUNCNAME(string &in asParent, string &in asChild, int alState)
{
FadeEnemyToSmoke("servant_grun_1", true);
}


so like that to make him spawn and despawn?


RE: Monster script - FlawlessHappiness - 11-23-2012

You forgot a t in grunt:
FadeEnemyToSmoke("servant_grun_1", true);


RE: Monster script - liquiddr3amz - 11-23-2012

thanks for the help, I'm at work so ill give this a try when i get home Smile is there any webpages that help explain the scripting, so i know to put stuff in the OnStart/OnEnter/OnLeave eg; or basically just read the wiki?


RE: Monster script - The chaser - 11-23-2012

(11-23-2012, 05:38 PM)liquiddr3amz Wrote: thanks for the help, I'm at work so ill give this a try when i get home Smile is there any webpages that help explain the scripting, so i know to put stuff in the OnStart/OnEnter/OnLeave eg; or basically just read the wiki?
http://wiki.frictionalgames.com/hpl2/start