Call of Duty: Black Ops III

Call of Duty: Black Ops III

Not enough ratings
[Scripting] Dynamically Spawning Actors
By Mysti and 1 collaborators
   
Award
Favorite
Favorited
Unfavorite
Introduction
Well, it's certainly been awhile. I've been busy with Wiork and other projects. Namely contributing to the offical Mod Tools Launcher Project found here[github.com].

This tutorial is aimed at people who want to spawn actors on trigger activations or the like. Similar to my Model or FX turtorials. I'll be using a zombie actor as an example. But don't expect him to follow you without you doing some coding to get it to act like a proper zombie. This can be used if you've created a "body guard" of sorts.

But enough talking. Let's get into the tutorial.
Radiant Requirements
So, for this part, all you're going to need is a script_origin.

Give it the following KVP
Key
Value
targetname
dyn_zombie_spawn

You can add as many script_origins as you'd like, but I am going to stick to one, and my code is going to be catered to one as well, bare that in mind before you try add more that one, you'll need to tweak my code.

Now for the trigger, I am going to keep it simple and use a trigger_use

Give it the following KVP
Key
Value
targetname
start_dyn_zombie_spawn

Anyway, let's get onto the fun part!
Scripting Requirements
Now we're into the fun part. First off, put
thread waitForTriggerSpawn();
in your MAPNAME.gsc under
level.pathdist_type = PATHDIST_ORIGINAL;

Now we paste this function all the way down the bottom of your code.
function waitForTriggerSpawn() { self endon( "disconnect" ); Start_ZMB_Spawn = getEnt("start_dyn_zombie_spawn","targetname"); Start_ZMB_Spawn sethintstring("Press [^3&&1^7] For Something!"); //Change Hint If You Want. Start_ZMB_Spawn SetCursorHint( "HINT_NOICON" ); //Change Icon If You Want. Start_ZMB_Spawn waittill("trigger", Player); ZMB_Spawn_Loc = getEnt("dyn_zombie_spawn","targetname"); SpawnActor("archetype_zm_factory_zombie", ZMB_Spawn_Loc GetOrigin(), ZMB_Spawn_Loc GetAngles()); //Change archetype_zm_factory_zombie To Your Zombie }

Now when you press E on that trigger a zombie will spawn! TaDa!
Zone File Requirements
Last little bit, make sure this line is in your MAPNAME.zone file.
//Replace archetype_zm_factory_zombie with the actor archetype you used. aitype,archetype_zm_factory_zombie
Final Words
Now, I know this guide is not exactly helpful, but this is just the start, next up, I'll write a tutorial on controlling how actors behave and assigning them behavior trees so they can react to what is going on around them.

But thanks for reading, and I'll catch you in the next one!

Thanks, Johnathon.