UGX-Mods

Call of Duty 5: World at War => Tutorial Desk => Scripting => Topic started by: isaacscott935 on June 11, 2018, 08:34:51 pm

Title: Shootable teddy bears [ORDERED] (for EE)
Post by: isaacscott935 on June 11, 2018, 08:34:51 pm
Hey guys

I created this script earlier today. This allows you to be able to shoot teddy bears in the map.
NOTE:You must shoot the teddies in the order it is in the script. Make sure to remember where you put Bear1,bear2 etc in radiant so you can test 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:
Code Snippet
Plaintext
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:

Code Snippet
Plaintext
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:

Code Snippet
Plaintext
targetname       bear1

So my second trigger's KVP would look like:

Code Snippet
Plaintext
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

Go into mapname\maps\mapname.gsc.

I have created a function called shootable_bears(), so you need to write:

Code Snippet
Plaintext
level thread shootable_bears();

underneath

Code Snippet
Plaintext
level thread DLC3_threadCalls2();

Next, at the bottom of your .GSC file, add your function:

Code Snippet
Plaintext
shootable_bears() //Shootable teddy bears in map. Make sure you add a trigger_multiple and add the KVPs. 
{
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();
iPrintLnBold("Poor Teddy 1 has been shot.");

//The first teddy has now been shot. You can now shoot the second one. When each one is shot, text will appear.

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();
iPrintLnBold("Teddy 2 has been shot, also.");

//Both teddies have now been shot.

players = get_players();
for(i=0;i<players.size;i++)
players[i] playsound( "insert_sound_here" );

}


NOTE: Make sure all of your targetnames in your script match the ones in your radiant file
KVPs.

This code

Code Snippet
Plaintext
players = get_players();
for(i=0;i<players.size;i++)
players[i] playsound( "insert_sound_here" );

is to add music once your teddies have been shot. I have not added music, hence the "insert_sound_here", but you can add a song to your map and play it using this code.

Enjoy
If there are any mistakes please let me know
Title: Re: Shootable teddy bears (for EE)
Post by: gympie6 on June 12, 2018, 05:48:37 am
Hey guys

I created this script earlier today. I am just learning scripting, so it might not be the most exciting/complex tutorial but here we are. This basically allows you to be able to shoot teddy bears in the map.

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:
Code Snippet
Plaintext
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:

Code Snippet
Plaintext
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:

Code Snippet
Plaintext
targetname       bear1

So my second trigger's KVP would look like:

Code Snippet
Plaintext
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

Go into mapname\maps\mapname.gsc.

I have created a function called shootable_bears(), so you need to write:

Code Snippet
Plaintext
level thread shootable_bears();

underneath

Code Snippet
Plaintext
level thread DLC3_threadCalls2();

Next, at the bottom of your .GSC file, add your function:

Code Snippet
Plaintext
shootable_bears() //Shootable teddy bears in map. Make sure you add a trigger_multiple and add the KVPs. 
{
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();
iPrintLnBold("Poor Teddy 1 has been shot.");

//The first teddy has now been shot. You can now shoot the second one. When each one is shot, text will appear.

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();
iPrintLnBold("Teddy 2 has been shot, also.");

//Both teddies have now been shot.

players = get_players();
for(i=0;i<players.size;i++)
players[i] playsound( "insert_sound_here" );

}


NOTE: Make sure all of your targetnames in your script match the ones in your radiant file
KVPs.

This code

Code Snippet
Plaintext
players = get_players();
for(i=0;i<players.size;i++)
players[i] playsound( "insert_sound_here" );

is to add music once your teddies have been shot. I have not added music, hence the "insert_sound_here", but you can add a song to your map and play it using this code.

Enjoy
If there are any mistakes please let me know

I think this tutorial is working fine but I see a problem there, you really need to shoot the first teddybear before you can shoot the second.
It can't be done otherwise.
Title: Re: Shootable teddy bears (for EE)
Post by: isaacscott935 on June 12, 2018, 06:14:37 am
Yes, I forgot to mention that. I’ll edit the original post. You have to remember which order you put them in the script and where you put them in radiant to test them.