----------------------------------------------------------------------------------
The setup:
First off, you'll need the script provided with Tres CE, which can be found in the "doc/scripting/samples/" folder within the CE package. The script you want is "Spitter.nut" - you'll be pasting it into your mod's Scripts folder, which is essentially a replacement for ATX's MAPS folder. If you don't already have a Scripts folder for your mod, create one in the base directory (where you can also find the Data folder). Paste the Spitter.nut file into this folder - you can rename it to whatever you want if you wanto to make things a bit more organized, it will still work fine.
The Spitter.nut script's contents:
Time for a quick explaination of what this script does, from my meagre understanding of it. While I don't really understand much of the language involved in the .NUT file (although it appears somewhat similar to LUA scripting, which I am familiar with), I was able to pinpoint the key things you need to make the Spitter work by reading through CE's documentation. Open up the Spitter.nut file with any text editor, such as Notepad or the likely better choice of Notepad++. We've got three Class definitions in here - SpitterHelper, SpitterProjectile, and Spitter. These define the induvidual scripts for each entity within Trespasser, which appear to be called "classes" in the scripting. You can see that the SpitterProjectile class has the "extends CInstance" setting, which means it can only be applied to a CInstance; likewise for the Spitter class, which can only be applied to a CAnimal. These scripts tell the game how to use the SpitterProjectile as a...well, projectile, and the Spitter when to attack, how to aim its spit, and etc. The other class is SpitterHelper, which is a LevelScript. It is automatically initialized upon level load and appears to reset itself through the scripting to prevent it from breaking when the level changes. It will load by itself in any level, although it seems possible to restrict such a script to certain levels which is explained in the documentation. For now, level the script as it is.
How to activate the script and make your dinosaur spit an object:
Now, how do we actually apply these scripts to a CInstance? It's extremely simple. With your script in the Scripts folder, boot up TresEd, preferrably a level which already has a Spitter set up. All you really need is a Spit Projectile CInstance and a CAnimal that will do the spitting, but for ease of use I went straight into TC~Isle as it already has the triggers neccessary for hit detection and the dilophosaur's frill to unfold. First, you'll want to find your Spit Projectile instance and go into its T-Script. Add the line "string Script = "SpitterProjectile"" and save the script. TresEd will freak out and inform you that Script isn't a valid function, but you can safely ignore this. This tiny addition tells the spit object to use the SpitterProjectile class we looked at in the .NUT script, so it should now function as the projectile when a dinosaur performs ActBite and spits. You'll now need to find the dinosaur you want to make spit and do the same to its T-Script, adding the "string Script =" line, but instead of making the string SpitterProjectile, you want to make it Spitter, so that the CAnimal uses the Spitter script. Save the script and that's it! You're done! All you have to do is add the Script string to your instances and make sure they are using the correct class as defined in your script. Head into the game and test it out to be sure it works.
----------------------------------------------------------------------------------
There are a few settings you can tweak in the Spitter.nut file as well, which can be found under the "Spitter Configuration" header:
- Spoiler: show
I hope this allows more people to use spitting dinosaurs in their levels since it's really as easy as adding a couple of lines (and importing the triggers from TC for hit detection and resetting the spit object, but I'll leave that up to you ).
In short, a recap:
1. Copy the Spitter.nut script to your mod's Scripts folder.
2. Find the CInstance you wish to use as the SpitProjectile in TresEd.
3. Add the "string Script = "SpitterProjectile"" line and save.
4. Find the CAnimal you wihs to make spit.
5. Add the "string Script = "Spitter" line and save.
6. You're ready to go!