Frictional Games Forum (read-only)

Full Version: Monster script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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);
}
Edit: Use this instead:

void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("stevie_1", true);
ShowEnemyPlayerPosition("stevie_1");
}
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?
(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
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"
AddEntityCollideCallback("servant_grunt_1", "ScriptArea_1", "FUNCNAME", true, 1);



This should go to your void OnStart().
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?
You forgot a t in grunt:
FadeEnemyToSmoke("servant_grun_1", true);
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?
(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?
[url]http://wiki.frictionalgames.com/hpl2/start[/url]
Pages: 1 2