Difference between revisions of "Scripting:AIBreathTutorial"

gravatar The Watcher [userbureaucratsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs)
(Created page with "Setting up the TWTrapAIBreath system is fairly simple, but it's important to note that directly attaching the particles to the AI will produce very odd-looking particle behavi...")
 
gravatar The Watcher [userbureaucratsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs)
 
(2 intermediate revisions by the same user not shown)
Line 15: Line 15:
 
* Click <code>Add</code> and enter the name <code>BreathProxy</code>
 
* Click <code>Add</code> and enter the name <code>BreathProxy</code>
 
* Open <code>Object -> SFX -> GasFX</code> and select <code>RoboSteam</code>
 
* Open <code>Object -> SFX -> GasFX</code> and select <code>RoboSteam</code>
* Click <code>Add</code>and enter the name <code>AIBreath</code>
+
* Click <code>Add</code> and enter the name <code>AIBreath</code>
 
* Select <code>AIBreath</code> and click <code>Edit</code>
 
* Select <code>AIBreath</code> and click <code>Edit</code>
 
* Add <code>SFX -> Particle Launch Info</code>
 
* Add <code>SFX -> Particle Launch Info</code>
Line 21: Line 21:
 
[[Image:AIBreath_PLI.png]]
 
[[Image:AIBreath_PLI.png]]
 
* Add <code>SFX -> Particles</code>
 
* Add <code>SFX -> Particles</code>
* Enter the following settings and click <code>OK</code>
+
* Enter the following settings and click <code>OK</code> (note that <code>Always simulate</code> seems to be forced by <code>Trailing Object</code>!)
 
[[Image:AIBreath_Particles.png]]
 
[[Image:AIBreath_Particles.png]]
 
* Finally add <code>Links -> ParticleAttachement</code> and set the link to go from <code>AIBreath</code> to <code>BreathProxy</code> (Note this should be <code>ParticleAttachement</code>, not <code>~ParticleAttachement</code>)
 
* Finally add <code>Links -> ParticleAttachement</code> and set the link to go from <code>AIBreath</code> to <code>BreathProxy</code> (Note this should be <code>ParticleAttachement</code>, not <code>~ParticleAttachement</code>)
Line 38: Line 38:
  
 
=== Room setup ===
 
=== Room setup ===
Now you have AIs that will have visible breath when they are in any room that is an instance of the the "Outside" room archetype:
+
Now you have AIs that will have visible breath when they are in any room that is an instance of the the <code>Outside</code> room archetype:
  
 
* Open the Object Hierarchy
 
* Open the Object Hierarchy
Line 47: Line 47:
 
* Start placing your outside rooms.
 
* Start placing your outside rooms.
  
If you want to use several different 'outside' room archetypes, just make sure you add the names to the TWTrapAIBreathColdRooms parameter in the design note.
+
If you want to use several different 'outside' room archetypes, just make sure you add the names to the <code>TWTrapAIBreathColdRooms</code> parameter in the design note.
  
With everything set up, you can place your AIs as normal and they will pick up the script and detail attachment automatically - if you are retrofitting an existing FM with the system, you will need to either delete and remake your existing AIs, or manually add the necessary BreathProxy object and DetailAttachement links for each.
+
With everything set up, you can place your AIs as normal and they will pick up the script and detail attachment automatically - if you are retrofitting an existing FM with the system, you will need to either delete and remake your existing AIs, or manually add the necessary <code>BreathProxy</code> object and <code>DetailAttachement</code> links for each.
  
 
{{Scripting:Navbox}}
 
{{Scripting:Navbox}}
 
{{:Site Navigation}}
 
{{:Site Navigation}}
 
<references />
 
<references />

Latest revision as of 10:49, 25 June 2020

Setting up the TWTrapAIBreath system is fairly simple, but it's important to note that directly attaching the particles to the AI will produce very odd-looking particle behaviour: you must use an intermediary marker as a detail attachment and attach the particles to that proxy object if you want the particles to behave sensibly.

You can find a complete example of this setup in the TWScriptDemo mission files, including the fpuff.tga file needed for the particles.

Obviously before you begin you should make sure that TWScript is loaded in your FM, or you'll end up with AIs constantly breathing out steam wherever they go!

The settings given here are only 'typical' examples - you should expect to need to tweak them to match the 'feel' of your FM and your own preferences. You may find it easier to fiddle with the settings on the AIs in the demo mission, and then copy the settings across into your own.


While this system has been tested on a small scale, it has not yet been deployed across a mission with dozens of AIs using the setup. I've tried to minimise the overhead of the script as much as possible, but if you have a very large number of AIs using this script, it may have performance implications - please tell me how it goes!


BreathProxy and AIBreath

The first step to setting up the system is to create the breath proxy marker and particle archetype:

  • Open the Object Hierarchy
  • Open Object -> fnord and select Marker
  • Click Add and enter the name BreathProxy
  • Open Object -> SFX -> GasFX and select RoboSteam
  • Click Add and enter the name AIBreath
  • Select AIBreath and click Edit
  • Add SFX -> Particle Launch Info
  • Enter the following settings and click OK

AIBreath PLI.png

  • Add SFX -> Particles
  • Enter the following settings and click OK (note that Always simulate seems to be forced by Trailing Object!)

AIBreath Particles.png

  • Finally add Links -> ParticleAttachement and set the link to go from AIBreath to BreathProxy (Note this should be ParticleAttachement, not ~ParticleAttachement)

AI Setup

Next you need to either modify existing AIs to add the TWTrapAIBreath setup, or create new archetypes of each AI that needs to have the system applied. It's likely that any AI that chases the player may end up being drawn into a cold area, so arguably you could add the necessary elements to physical -> Creature -> Animal -> Human, but there are no free Script slots on that archetype. The following gives instructions for modifying the existing guard archetype - you may want to add the modifications to the other Human subobjects:

  • Select Object -> physical -> Creature -> Animal -> Human -> guard and click Edit
  • Add Editor -> Design Note and set the design note to, for example:
TWTrapAIBreathColdRooms=Outside;TWTrapAIBreathExhaleTime=600
  • Select Scripts and click Edit
  • Add TWTrapAIBreath to the list of scripts
  • Add Links -> ~DetailAttachement and make the link go from guard to BreathProxy
  • Edit the data for the newly added link, and set the values to the following - this should place the BreathProxy object in front of the face of most AIs:

AIBreath DAData.png

Room setup

Now you have AIs that will have visible breath when they are in any room that is an instance of the the Outside room archetype:

  • Open the Object Hierarchy
  • From Show Tree select Rooms
  • Select Base Room -> Default Room
  • Click Add and enter the name Outside
  • Click Create
  • Start placing your outside rooms.

If you want to use several different 'outside' room archetypes, just make sure you add the names to the TWTrapAIBreathColdRooms parameter in the design note.

With everything set up, you can place your AIs as normal and they will pick up the script and detail attachment automatically - if you are retrofitting an existing FM with the system, you will need to either delete and remake your existing AIs, or manually add the necessary BreathProxy object and DetailAttachement links for each.


Authors

  • gravatar The Watcher [userbureaucratsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+]

Looking for something?

Use the form below to search the wiki:

 

Still not finding what you are looking for? Contact us so we can take care of it!