User Tools

Site Tools


hpl2:tutorials:scripting:triggering_monsters_on_entities

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
hpl2:tutorials:scripting:triggering_monsters_on_entities [2011/07/21 18:36]
jenniferorange created
hpl2:tutorials:scripting:triggering_monsters_on_entities [2011/07/21 18:50] (current)
jenniferorange
Line 2: Line 2:
  
  
-__**<​font 18pt:​normal/​Arial;;​inherit;;​inherit>​Setting Up The Room(s)</​font>​ ** __ +__**<​font 18pt:​normal/​Arial;;​inherit;;​inherit ​ >Setting Up The Room(s)</​font>​ ** __ 
  
  
Line 8: Line 8:
  
  
-__**<​font 18pt:​normal/​Arial;;​inherit;;​inherit>​Scripting It</​font>​ ** __ +__**<​font 18pt:​normal/​Arial;;​inherit;;​inherit ​ >​Scripting It</​font>​ ** __ 
  
  
-Open your maps .hps file. The first thing we need to do is script the key to unlock a door somewhere else. Choose the door you'd like the key to unlock, **BUT NOT THE DOOR THE MONSTER BREAKS DOWN, BECAUSE IT'S POINTLESS**,​ and re-name it to whatever you'd like. I named mine **locked_door1**. We need to make an AddUseItemCallBack for the key. +Open your maps .hps file. The first thing we need to do is script the key to unlock a door somewhere else. Choose the door you'd like the key to unlock, **BUT NOT THE DOOR THE MONSTER BREAKS DOWN, BECAUSE IT'S POINTLESS**,​ and re-name it to whatever you'd like. I named mine **locked_door1**. We need to make an AddUseItemCallBack for the key.
  
  
-[code]void OnStart()\\  ​{  ​\\      ​AddUseItemCallback("",​ "​key_1",​ "​locked_door1",​ "​UsedKeyOnDoor",​ true);[/code]+<​plugin ​ title="​stet"​ ></​plugin>​ 
 + 
 + 
 +<code actionscript>​void OnStart() 
 +{ 
 +  ​AddUseItemCallback("",​ "​key_1",​ "​locked_door1",​ "​UsedKeyOnDoor",​ true); 
 +</code>
  
  
Line 20: Line 26:
  
  
-[code]void OnStart()\\  ​{  ​\\      ​AddUseItemCallback("",​ "​key_1",​ "​locked_door1",​ "​UsedKeyOnDoor",​ true);\\  ​SetEntityCallbackFunc("​key_1",​ "**OnPickup**");\\  ​}[/code]+<code actionscript>​void OnStart() 
 +{  ​ 
 +   AddUseItemCallback("",​ "​key_1",​ "​locked_door1",​ "​UsedKeyOnDoor",​ true); 
 +   SetEntityCallbackFunc("​key_1",​ "​OnPickup"​);​ 
 +} 
 +</code>
  
  
 **OnPickup ** is the name of the function we are going to call. Now we can finish scripting the key.. **OnPickup ** is the name of the function we are going to call. Now we can finish scripting the key..
 +<code actionscript>​void OnStart()
 +{  ​
 +  AddUseItemCallback("​key_1",​ "​locked_door1",​ "​UsedKeyOnDoor",​ true);
 +  SetEntityCallbackFunc("​key_1",​ "​OnPickup"​);​
 +}
 +void UsedKeyOnDoor(string &in asItem, string &in asEntity)
 +{
 +  SetSwingDoorLocked("​locked_door1",​ false, true);
 +  PlaySoundAtEntity("",​ "​unlock_door.snt",​ "​locked_door1",​ 0, false);
 +  RemoveItem("​key_1"​);​
 +}
 +</​code>​
  
  
-[code]void OnStart()\\ ​ {  \\      AddUseItemCallback("",​ "​key_1",​ "​**locked_door1**",​ "​UsedKeyOnDoor",​ true);​\\ ​ SetEntityCallbackFunc("​key_1",​ "​OnPickup"​);​\\ ​ }\\  \\  void UsedKeyOnDoor(string &in asItem, string &in asEntity)\\ ​ {\\  SetSwingDoorLocked("​**locked_door1**",​ false, true);​\\ ​ PlaySoundAtEntity("",​ "​unlock_door.snt",​ "​locked_door1",​ 0, false);​\\ ​ RemoveItem("​key_1"​);​\\ ​ }[/code] +You can change the name of my door, **locked_door1**,​ to the name of your locked door, which is **NOT THE DOOR THE MONSTER BREAKS DOWN**.
- +
- +
-You can change the name of my door, **locked_door1**,​ to the name of your locked door, which is **%%*%%** ​**NOT THE DOOR THE MONSTER BREAKS DOWN%%*%%**.+
  
  
Line 35: Line 55:
  
  
-[code]void OnStart()\\  ​{  ​\\      ​AddUseItemCallback("",​ "​key_1",​ "​locked_door1",​ "​UsedKeyOnDoor",​ true);\\  ​SetEntityCallbackFunc("​key_1",​ "**OnPickup**");\\  ​}\\  \\  ​void UsedKeyOnDoor(string &in asItem, string &in asEntity)\\  ​{\\  ​SetSwingDoorLocked("​locked_door1",​ false, true);\\  ​PlaySoundAtEntity("",​ "​unlock_door.snt",​ "​locked_door1",​ 0, false);\\  ​RemoveItem("​key_1"​);​\\  ​}\\  \\  ​void **OnPickup** (string &in asEntity, string &in type)\\  ​{\\  ​SetEntityActive("​monster_grunt",​ true);\\  ​ShowEnemyPlayerPosition("​monster_grunt"​);​\\  ​}\\  [/code]+<code actionscript>​void OnStart() 
 +{  ​ 
 +  ​AddUseItemCallback("",​ "​key_1",​ "​locked_door1",​ "​UsedKeyOnDoor",​ true); 
 +  ​SetEntityCallbackFunc("​key_1",​ "​OnPickup"​);​ 
 +} 
 +void UsedKeyOnDoor(string &in asItem, string &in asEntity) 
 +{ 
 +  ​SetSwingDoorLocked("​locked_door1",​ false, true); 
 +  ​PlaySoundAtEntity("",​ "​unlock_door.snt",​ "​locked_door1",​ 0, false); 
 +  ​RemoveItem("​key_1"​);​ 
 +} 
 +void OnPickup(string &in asEntity, string &in type) 
 +{ 
 +  ​SetEntityActive("​monster_grunt",​ true); 
 +  ​ShowEnemyPlayerPosition("​monster_grunt"​);​ 
 +} 
 +</code>
  
  
-Make sure the callback function is the same name. (**OnPickup**) The script shows that after you pick up the **key_1**, **monster_grunt ** will activate, and I added ShowEnemyPlayerPosition,​ which will show the grunt where the player is, so he doesn'​t wander aimlessly in the other room. Make sure there'​s a closet in that room too, you'll need somewhere to hide! (unless you make him a hallucination) That's it for your .hps file! You can finish scripting your key in your extra_english.lang file by using Xtrons tutorial on how to make an item unlock a door, which you can find here: +Make sure the callback function is the same name. (**OnPickup**) The script shows that after you pick up the **key_1**, **monster_grunt ** will activate, and I added ShowEnemyPlayerPosition,​ which will show the grunt where the player is, so he doesn'​t wander aimlessly in the other room. Make sure there'​s a closet in that room too, you'll need somewhere to hide! (unless you make him a hallucination) That's it for your .hps file! You can finish scripting your key in your extra_english.lang file by using Xtrons tutorial on how to make an item unlock a door, which you can find here:
  
  
-http://​wiki.frictionalgames.com/​hpl2/​tutorials/​script/​scripting_by_xtron_-_item_that_unlocks_a_door+[[http://​wiki.frictionalgames.com/​hpl2/​tutorials/​script/​scripting_by_xtron_-_item_that_unlocks_a_door|http://​wiki.frictionalgames.com/​hpl2/​tutorials/​script/​scripting_by_xtron_-_item_that_unlocks_a_door]] ​
  
  
 Thanks for tuning in to this tutorial! Thanks for tuning in to this tutorial!
 +
 +
 +Created by JenniferOrange
  
hpl2/tutorials/scripting/triggering_monsters_on_entities.1311273419.txt.gz · Last modified: 2011/07/21 18:36 by jenniferorange