User Tools

Site Tools


hpl3:community:other:monsters

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
hpl3:community:other:monsters [2015/10/07 15:18]
romulator [In Script]
hpl3:community:other:monsters [2015/10/29 15:27] (current)
romulator
Line 74: Line 74:
           return true;           return true;
           }           }
-     //​More Code Here... ​     }+     //​More Code Here... ​       
 +     }
 </​code>​ </​code>​
  
Line 87: Line 88:
  
 Now, I'm not entirely sure what this does, but my whole code errored without it. If you are familiar with HPL2, this is different, since you need to include this line of code at the beginning and pretty much the rest of your voids, bools, and other subroutines occur within the braces. Now, I'm not entirely sure what this does, but my whole code errored without it. If you are familiar with HPL2, this is different, since you need to include this line of code at the beginning and pretty much the rest of your voids, bools, and other subroutines occur within the braces.
 +
 +However, if you would like to get an understanding of that particular line, TheGreatCthulhu explains its purpose in [[https://​www.frictionalgames.com/​forum/​thread-31123-post-329205.html#​pid329205|this forum post]]. Be warned that it is some pretty extensive information,​ but give it a few reads and you should be good!
  
 <code c++>void OnStart() <code c++>void OnStart()
Line 96: Line 99:
 </​code>​ </​code>​
  
-**void OnStart()** is an event where you can declare anything which you require to begin as you start the map. OnStart() only occurs in the first occurence of the map loading - therefore, if you backtrack to this level, the code here will not be called upon return. If you need such to occur, use OnEnter(). (Learn about [[:​hpl2:​amnesia:​script_language_reference_and_guide:​execution_flow|Execution Flow here]] for more information).+**void OnStart()** ​ is an event where you can declare anything which you require to begin as you start the map. OnStart() only occurs in the first occurence of the map loading - therefore, if you backtrack to this level, the code here will not be called upon return. If you need such to occur, use OnEnter(). (Learn about [[:​hpl2:​amnesia:​script_language_reference_and_guide:​execution_flow|Execution Flow here]] for more information). 
 + 
 +**Entity_AddCollideCallback();​** ​ is a callback. Adding a callback declares that you want a particular number of events to occur which you will define later on in your code. The syntax of Entity_AddCollideCallback();​ is the following:
  
-**Entity_AddCollideCallback();​** is a callback. Adding a callback declares that you want a particular number of events to occur which you will define later on in your code. The syntax of Entity_AddCollideCallback();​ is the following: 
 <code c++> <code c++>
 Entity_AddCollideCallback(const tString &in asParentName,​ const tString &in asChildName,​ const tString &in asFunction);​ Entity_AddCollideCallback(const tString &in asParentName,​ const tString &in asChildName,​ const tString &in asFunction);​
 </​code>​ </​code>​
  
-**const tString &in asParentName:​** The name of the parent entity as declared in the Level Editor which collides with the child. Usually the "​moving"​ entity. Can be "​Player"​ to mean the player. ​    ​\\ +**const tString &in asParentName:​** ​ The name of the parent entity as declared in the Level Editor which collides with the child. Usually the "​moving"​ entity. Can be "​Player"​ to mean the player. ​     \\ **const tString &in asChildName:​ **  The name of the child entity to collide with - usually not moving. In this case, I have made it a Trigger Area called opendoor. ​    ​\\ **const tString &in asFunction:​** ​ The name of the function as named in the code. I called it "​Open_Door",​ since that is what my function will do. 
-**const tString &in asChildName:​ ** The name of the child entity to collide with - usually not moving. In this case, I have made it a Trigger Area called opendoor. ​   \\ + 
-**const tString &in asFunction:​** The name of the function as named in the code. I called it "​Open_Door",​ since that is what my function will do.+Furthermore,​ because we have a Callback, we need to know the **Callback Syntax** ​ in order for the engine to find the sequence of events to run through. Entity_AddCollideCallback'​s Callback Syntax is this
  
-Furthermore,​ because we have a Callback, we need to know the **Callback Syntax** in order for the engine to find the sequence of events to run through. Entity_AddCollideCallback'​s Callback Syntax is this 
 <code c++> <code c++>
 bool asFunction(const tString &in asParent, const tString &in asChild, int alState) bool asFunction(const tString &in asParent, const tString &in asChild, int alState)
Line 151: Line 154:
 </​code>​ </​code>​
  
-**const tString &in asName: ** The name of the entity to active or deactivate. If it is deactivated,​ it becomes invisible in game.    \\ +**const tString &in asName: **  The name of the entity to active or deactivate. If it is deactivated,​ it becomes invisible in game.     ​\\ **bool abActive: **  Whether the entity is visible or invisible. true = visible, false = invisible 
-**bool abActive: ** Whether the entity is visible or invisible. true = visible, false = invisible+
 <code c++> <code c++>
 Pathfinder_Track_Add("​maintenance_infected_1",​ "​PathNodeArea_1",​ 0.0f, 0.5f, "",​ false); Pathfinder_Track_Add("​maintenance_infected_1",​ "​PathNodeArea_1",​ 0.0f, 0.5f, "",​ false);
Line 175: Line 178:
 </​code>​ </​code>​
  
-**const tString&​in asEntityName:​** The name of the entity to assign the pathnodes to.     ​\\ +**const tString&​in asEntityName:​** ​ The name of the entity to assign the pathnodes to.      \\ **const tString&​in asNodeName: **  The name of the pathnode to add to the sequence of pathnodes available for the entity. ​     \\ **float afMinWaitTime:​ **  The minimum amount of time to wait at the pathnode before continuing. ​     \\ **float afMaxWaitTime:​** ​ The maximum amount of time to wait at the pathnode before continuing. ​     \\ **const tString&​in asAnimName: **  The name of the animation the entity will play upon reaching the pathnode. ​     \\ **bool abLoopAnim:​** ​ If the animation should be looped each time the entity arrives at that particular pathnode. 
-**const tString&​in asNodeName: ** The name of the pathnode to add to the sequence of pathnodes available for the entity. ​    ​\\ +
-**float afMinWaitTime:​ ** The minimum amount of time to wait at the pathnode before continuing. ​    ​\\ +
-**float afMaxWaitTime:​** The maximum amount of time to wait at the pathnode before continuing. ​    ​\\ +
-**const tString&​in asAnimName: ** The name of the animation the entity will play upon reaching the pathnode. ​    ​\\ +
-**bool abLoopAnim:​** If the animation should be looped each time the entity arrives at that particular pathnode.+
 <code c++> <code c++>
 Pathfinder_Track_Start(const tString &in asEntityName,​ bool abLoop, float afUpdateFreq,​ const tString &in asEndOfTrackCallback);​ Pathfinder_Track_Start(const tString &in asEntityName,​ bool abLoop, float afUpdateFreq,​ const tString &in asEndOfTrackCallback);​
 </​code>​ </​code>​
  
-**const tString&​in asEntityName:​ ** The entity in which will start patrolling once assigned pathnodes through Pathfinder_Track_Add(); ​    ​\\ +**const tString&​in asEntityName:​ **  The entity in which will start patrolling once assigned pathnodes through Pathfinder_Track_Add(); ​     \\ **bool abLoop:​** ​ If, when the sequence of pathnodes has ended, the entity follows the same path again. ​     \\ **float afUpdateFreq:​** ​ How often the path is recalculated. Default is 1.0f (recalculated every second). Should be enough. ​     \\ **const tString &in asEndOfTrackCallback:​** ​ A callback to call once the track has ended. Not needed here, so it will not be explained further. 
-**bool abLoop:** If, when the sequence of pathnodes has ended, the entity follows the same path again. ​    ​\\ +
-**float afUpdateFreq:​** How often the path is recalculated. Default is 1.0f (recalculated every second). Should be enough. ​    ​\\ +
-**const tString &in asEndOfTrackCallback:​** A callback to call once the track has ended. Not needed here, so it will not be explained further.+
 <code c++> <code c++>
 SlideDoor_SetClosed("​slidedoor_theta_tunnels_2",​ false); SlideDoor_SetClosed("​slidedoor_theta_tunnels_2",​ false);
Line 195: Line 192:
 This quite simply opens the SlideDoor. I included it as part of my code to test if I could open doors with triggers, and so that the monster spawns behind a door, rather than in direct line of sight (immersion breaking). This quite simply opens the SlideDoor. I included it as part of my code to test if I could open doors with triggers, and so that the monster spawns behind a door, rather than in direct line of sight (immersion breaking).
  
-We also keep the **return true; ** line because the callback is of boolean type. When we collide with it, we return "​true"​ to the collision in order to trigger it.+We also keep the **return true; **  line because the callback is of boolean type. When we collide with it, we return "​true"​ to the collision in order to trigger it.
  
 As you can see, it is a bit complicated. Scripting is not easy to start with, but when you begin to recognise the patterns, then you will get the hang of it. Never copy and paste code unless you understand what is actually happening, else you won't learn and will struggle with much more advanced forms of coding. As you can see, it is a bit complicated. Scripting is not easy to start with, but when you begin to recognise the patterns, then you will get the hang of it. Never copy and paste code unless you understand what is actually happening, else you won't learn and will struggle with much more advanced forms of coding.
Line 201: Line 198:
 ===== How can I learn more? ===== ===== How can I learn more? =====
  
-Well, for starters, you can explore my map if you would like! You can download it from [[https://​www.dropbox.com/​s/​hq5dukyv6idhrdt/​monster_map.zip?​dl=0|this dropbox link]].+Well, for starters, you can explore my map if you would like! You can download it from [[https://​www.dropbox.com/​s/​hq5dukyv6idhrdt/​monster_map.zip?​dl=0|this dropbox link]]. ​However, beware that there is more code, and my pathnodes use a "​For"​ Loop. You can read about "​For"​ Loops here: 
 + 
 +    * [[:​hpl2:​tutorials:​script:​forloop|"​For"​ Loops]] 
 +    * [[:​hpl2:​amnesia:​script_language_reference_and_guide:​control_flow_-_loops|Control Flow: Loops]]
  
 Other ways of learning could be to go through SOMA's maps to see if you can figure out where and how they did a particular sequence of events. Most of the code above was done using this very method. Other ways of learning could be to go through SOMA's maps to see if you can figure out where and how they did a particular sequence of events. Most of the code above was done using this very method.
hpl3/community/other/monsters.1444231103.txt.gz · Last modified: 2015/10/07 15:18 by romulator