giacomo9
Junior Member
Posts: 37
Threads: 11
Joined: Nov 2012
Reputation:
0
|
Monster script
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
////////////////////////////
// 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);
}
|
|
11-19-2012, 10:46 PM |
|
Rowzter
Junior Member
Posts: 44
Threads: 12
Joined: Oct 2012
Reputation:
3
|
RE: Monster script
Edit: Use this instead:
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("stevie_1", true);
ShowEnemyPlayerPosition("stevie_1");
}
(This post was last modified: 11-19-2012, 11:07 PM by Rowzter.)
|
|
11-19-2012, 10:59 PM |
|
giacomo9
Junior Member
Posts: 37
Threads: 11
Joined: Nov 2012
Reputation:
0
|
RE: Monster script
Thank You very much, it works
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 |
|
Rowzter
Junior Member
Posts: 44
Threads: 12
Joined: Oct 2012
Reputation:
3
|
RE: Monster script
(11-19-2012, 11:13 PM)giacomo9 Wrote: Thank You very much, it works
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
(This post was last modified: 11-19-2012, 11:22 PM by Rowzter.)
|
|
11-19-2012, 11:20 PM |
|
liquiddr3amz
Junior Member
Posts: 14
Threads: 5
Joined: Nov 2012
Reputation:
0
|
RE: Monster script
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"
|
|
11-23-2012, 08:16 AM |
|
The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
|
RE: Monster script
AddEntityCollideCallback("servant_grunt_1", "ScriptArea_1", "FUNCNAME", true, 1);
This should go to your void OnStart().
THE OTHERWORLD (WIP)
Aculy iz dolan.
|
|
11-23-2012, 08:52 AM |
|
liquiddr3amz
Junior Member
Posts: 14
Threads: 5
Joined: Nov 2012
Reputation:
0
|
RE: Monster script
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?
|
|
11-23-2012, 04:33 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: Monster script
You forgot a t in grunt:
FadeEnemyToSmoke("servant_grun_1", true);
Trying is the first step to success.
|
|
11-23-2012, 05:27 PM |
|
liquiddr3amz
Junior Member
Posts: 14
Threads: 5
Joined: Nov 2012
Reputation:
0
|
RE: Monster script
thanks for the help, I'm at work so ill give this a try when i get home 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 |
|
The chaser
Posting Freak
Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation:
113
|
RE: Monster script
(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 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
THE OTHERWORLD (WIP)
Aculy iz dolan.
|
|
11-23-2012, 05:57 PM |
|
|