UGX-Mods

Call of Duty: Black Ops 3 => Tutorial Desk => Scripting => Topic started by: shinged on November 14, 2016, 11:11:01 pm

Title: [Tutorial] Simple Teleport Zombies Script
Post by: shinged on November 14, 2016, 11:11:01 pm
Hey guys, here is a simple script to add ways to teleport zombies in your map. So lets say you have a map with multiple zones and those zones are spaced apart, normally you would need to have a way for the zombies to get to the other like a hidden tunnel or something, this script is a good replacement for that. Here's a quick vid of it:


Radiant
The setup for this is very simple. The zombies need to be able to path to the area they are teleporting too. This can be done in a bunch of different creative ways such as using player clips or setting walls to non-colliding.
 - First create a trigger_multiple and give it this KVP "teleport_zombies" -  targetname.
 - Now create a script origin and place it halfway into the ground. Open the KVP's and set it to server. Now deselect everything, select the trigger first, then select the script_origin and hit W. What this will do is set the script_origin's targetname to an auto generated name so it can be copied without sharing targetnames.
 - Now you should see a line connecting the trigger to the origin. Double check to make sure its the trigger_multiple targeting script_origin and your good to go.
 - To add multiple teleporters just select the trigger and the origin and hit space. Check the kvp's to make sure the targetname on the origin is different from the targetname on the other origin and your done with radiant.

Here is an example of how i have mine setup, the clip is a clip_ai and not a player clip so only the zombies can cross that path.
(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FUzuoTKo.png&hash=bd5c5347b67c195892ff67e2170afa9d73c3ab6f)

Scripting
The scripting is extremely simple. Just open your mapname.gsc and copy this code.
Spoiler: click to open...
Code Snippet
Plaintext
/*
TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~
TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~
TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~
*/
function teleport_zombies_init()
{
teleport_trig = GetEntArray( "teleport_zombies", "targetname" );
for (i = 0; i < teleport_trig.size; i++)
{
teleport_trig[i] thread teleport_zombies();
}
}

function teleport_zombies()
{
teleport_destination = GetEnt( self.target, "targetname" );
while(1)
{
zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if( zombs[k] IsTouching( self ) )
{
zombs[k] ForceTeleport( teleport_destination.origin );
}
}
wait(0.01);
}
}

 - Paste that code into the bottom of your mapname.gsc.
 - Now at the bottom of the main function paste this
Code Snippet
Plaintext
thread teleport_zombies_init();
- It should look something like this:
Code Snippet
Plaintext
function main()
{
zm_usermap::main();

level._zombie_custom_add_weapons =&custom_add_weapons;

//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );

level.pathdist_type = PATHDIST_ORIGINAL;

thread teleport_zombies_init();
}

Now your done! Make sure when setting this up that the zombies are able to path to the destination otherwise they wont go into the portals. Also make sure to space the origin away from the portal a bit to avoid an infinite loop.

Let me know if you guys would like more simple scripting tutorial's like this.
Title: Re: [Tutorial] Simple Teleport Zombies Script
Post by: reckfullies on November 15, 2016, 01:15:19 am
Hey guys, here is a simple script to add ways to teleport zombies in your map. So lets say you have a map with multiple zones and those zones are spaced apart, normally you would need to have a way for the zombies to get to the other like a hidden tunnel or something, this script is a good replacement for that. Here's a quick vid of it:
(Content removed from quote.)

Spoiler: click to open...
Radiant
The setup for this is very simple. The zombies need to be able to path to the area they are teleporting too. This can be done in a bunch of different creative ways such as using player clips or setting walls to non-colliding.
 - First create a trigger_multiple and give it this KVP "teleport_zombies" -  targetname.
 - Now create a script origin and place it halfway into the ground. Open the KVP's and set it to server. Now deselect everything, select the trigger first, then select the script_origin and hit W. What this will do is set the script_origin's targetname to an auto generated name so it can be copied without sharing targetnames.
 - Now you should see a line connecting the trigger to the origin. Double check to make sure its the trigger_multiple targeting script_origin and your good to go.
 - To add multiple teleporters just select the trigger and the origin and hit space. Check the kvp's to make sure the targetname on the origin is different from the targetname on the other origin and your done with radiant.

Here is an example of how i have mine setup, the clip is a clip_ai and not a player clip so only the zombies can cross that path.
(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FUzuoTKo.png&hash=bd5c5347b67c195892ff67e2170afa9d73c3ab6f)

Scripting
The scripting is extremely simple. Just open your mapname.gsc and copy this code.
Spoiler: click to open...
Code Snippet
Plaintext
/*
TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~
TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~
TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~ TELEPORT ZOMBIES ~
*/
function teleport_zombies_init()
{
teleport_trig = GetEntArray( "teleport_zombies", "targetname" );
for (i = 0; i < teleport_trig.size; i++)
{
teleport_trig[i] thread teleport_zombies();
}
}

function teleport_zombies()
{
teleport_destination = GetEnt( self.target, "targetname" );
while(1)
{
zombs = getaispeciesarray("axis","all");
for(k=0;k<zombs.size;k++)
{
if( zombs[k] IsTouching( self ) )
{
zombs[k] ForceTeleport( teleport_destination.origin );
}
}
wait(0.01);
}
}

 - Paste that code into the bottom of your mapname.gsc.
 - Now at the bottom of the main function paste this
Code Snippet
Plaintext
thread teleport_zombies_init();
- It should look something like this:
Code Snippet
Plaintext
function main()
{
zm_usermap::main();

level._zombie_custom_add_weapons =&custom_add_weapons;

//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );

level.pathdist_type = PATHDIST_ORIGINAL;

thread teleport_zombies_init();
}

Now your done! Make sure when setting this up that the zombies are able to path to the destination otherwise they wont go into the portals. Also make sure to space the origin away from the portal a bit to avoid an infinite loop.

Let me know if you guys would like more simple scripting tutorial's like this.

Nice tutorial, this could be used in all sorts of ways. A cool thing anyone using this could also do is just add some fx to them when they teleport to make it seem like they aren't just appearing.
Title: Re: [Tutorial] Simple Teleport Zombies Script
Post by: cronex on December 02, 2016, 12:34:52 pm
Yeah cool TUT :)
Now my question, how can i do this teleport with walls at all 4 sides, like a room ?
the zombies wont go into the portals ?

thanks man
Title: Re: [Tutorial] Simple Teleport Zombies Script
Post by: IceGrenade on December 03, 2016, 04:11:23 pm
Yeah cool TUT :)
Now my question, how can i do this teleport with walls at all 4 sides, like a room ?
the zombies wont go into the portals ?

thanks man

Set the wall to non-collidable... then put a player clip over the wall... aka it will block players... but allow zombs to path. ;)

Double Post Merge: December 03, 2016, 04:12:07 pm
Also, epic stuff OP... I am excited to try it out :D
Title: Re: [Tutorial] Simple Teleport Zombies Script
Post by: spainking on December 27, 2016, 02:06:03 pm
Hello, Nice Tut! It works very nice but i have a question, how can i make that the zombies only teleport if i am in my 4th zone?
Thx
Title: Re: [Tutorial] Simple Teleport Zombies Script
Post by: FlowMaker on January 25, 2017, 01:08:39 pm
Hello, can anyone help me?
I did everything that was said in the tutorial but it did not work could you solve the problem?

https://www.noelshack.com/2017-04-1485349656-1.png (https://www.noelshack.com/2017-04-1485349656-1.png)
https://www.noelshack.com/2017-04-1485349667-2.png (https://www.noelshack.com/2017-04-1485349667-2.png)
https://www.noelshack.com/2017-04-1485349667-capture.png (https://www.noelshack.com/2017-04-1485349667-capture.png)