Shootable teddy bears [UNORDERED] (for EE)

broken avatar :(
Created 181 days ago
by isaacscott935
0 Members and 1 Guest are viewing this topic.
469 views
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 24 September 2016
Last active: 1 day ago
Posts
139
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
ZombieSlayerr115
Signature
Please. Save me.
×
isaacscott935's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
isaacscott935's Contact & Social LinksZombieSlayerr115isaac935
Hey guys

Yesterday I put up a tutorial on how to add a shootable model easter egg, so you can activate a door or play a song. That script only worked if you did the bears in order, which means you have to memorise where you placed the first, second and so on bears when testing it.
Today, I bring you my own unordered shootable bears/any other model tutorial, which makes it a lot better. I was thinking about how to do this and I realised you must have different functions for each of the bears (this is the only way I could work out how to do it).

The first part of this tutorial (the radiant part) will just be copy&pasted from the tutorial I put up yesterday because there's no need for me to rewrite it.

PART 1: RADIANT

 First, let's start off in radiant. Right click on your 2D window, and click script -> model. Find the zombie teddybear model. You can actually have this as any model, but I'll just use it (the model name for the bear is "zombie_teddybear"). You can place this anywhere in your map, as long as your player can see it.

Give this bear the KVP:
targetname         teddy1

You can then duplicate the script_model to have as many as you like, but make sure you change the KVP each time:

So, my second one would look like:

targetname       teddy2 
     etc.

Right click on your 2D window again and select trigger -> damage. Cover the bear with this trigger and hit N on your keyboard to give it KVPs. First, tick the box MELEE_NO (because we don't want to knife our bear). Then, add:

targetname       bear1

So my second trigger's KVP would look like:

targetname         bear2 
      etc.

Make sure you cover all of your bears with the trigger_damage and make sure all the KVPs are different.

PART 2: SCRIPTING

As I said, this scripting part is different.

Go to your mapname\maps\mapname.gsc file and open it.

About line 130, you'll find:

level thread DLC3_threadCalls2();

Underneath that, put in:

level thread bear1();
level thread bear2();
level.BearNumberShot = 0;

This calls all of the functions that we are going to create.

Now, at the bottom of your file, paste:

bear1()
{
teddy_1_trigger = getEnt("bear1","targetname");
teddy_1_model = getEnt("teddy1","targetname");
teddy_1_trigger waittill("trigger");
teddy_1_trigger Delete();
teddy_1_model Delete();

level.BearNumberShot ++;

iPrintLnBold("Poor Teddy 1 has been shot."); // iPrintLn prints in top left corner, iPrintLnBold prints in centre.
if ( level.BearNumberShot == 2 )
{
level thread bears_complete();

}

}

and underneath that, paste:

bear2()
{
teddy_2_trigger = getEnt("bear2","targetname");
teddy_2_model = getEnt("teddy2","targetname");
teddy_2_trigger waittill("trigger");
teddy_2_trigger Delete();
teddy_2_model Delete();

level.BearNumberShot ++;

iPrintLnBold("Teddy 2 has been shot, also.");
if ( level.BearNumberShot == 2 )
{
level thread bears_complete();

}

}

You may notice that each function contains an IF statement, which contains
level thread bears_complete();
. We have not defined that function yet, so that's what we're going to do.
So, paste this underneath your other functions:

bears_complete() // Function which displays the text when both of the bears/triggers have been shot, no matter the order. 
{
iPrintLnBold("Both bears have been killed. Well done!");

players = get_players();
for(i=0;i<players.size;i++)
players[i] playsound( "insert_sound_here" ); // Plays music once both bears have been shot.

}
This code is finished. Check that your targetnames are the same in the script as they are in the radiant triggers/models.

Again, this code:

players = get_players();
for(i=0;i<players.size;i++)
players[i] playsound( "insert_sound_here" ); // Plays music once both bears have been shot.


allows a song to be played once all bears have been shot. You can add your own music; there are plenty of tutorials on that.

Enjoy. If there are any mistakes please mention it :D
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 19 June 2018
Last active: 21 hours ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
cpt_johnson1's Groups
cpt_johnson1's Contact & Social Links
So I did everything and I made it give me a gun instead of a song, but right when I load up my map, it says that I shot the teddy bears and it gives me the gun. Do you know how to fix this?

Never mind, I got it working, I messed up the targetnames. I'll make sure to give you credit when my map releases
Last Edit: October 22, 2018, 07:08:49 pm by cpt_johnson1

 
Loading ...