UGX-Mods

Call of Duty 5: World at War => Tutorial Desk => Scripting => Topic started by: isaacscott935 on June 12, 2018, 05:27:10 pm

Title: Shootable teddy bears [UNORDERED] (for EE)
Post by: isaacscott935 on June 12, 2018, 05:27:10 pm
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:
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

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:

Code Snippet
Plaintext
level thread DLC3_threadCalls2();

Underneath that, put in:

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

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

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

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

Code Snippet
Plaintext
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
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: cpt_johnson1 on October 22, 2018, 06:57:13 pm
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
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: killadumb on July 08, 2019, 02:24:58 pm
The finished bears_complete() thread triggers when I start the game. Not after I do what I setup. Any help?
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: cpt_johnson1 on July 12, 2019, 06:42:46 pm
The finished bears_complete() thread triggers when I start the game. Not after I do what I setup. Any help?
This happened to me, and it was because I messed up the targetnames on the bears. Make sure you check all of the kvp's carefully
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: Stiffy on March 27, 2020, 04:34:11 am
How do i use this to open a door?
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: bonse2000 on May 31, 2020, 07:10:20 am
i need help when i run build a take error MODSound -pc -ignore_orphans  error2057

please i need help i have make your teddy bear shootable script it is work thank you but i want put music haow can i do it  have see tutorials but nothing please help
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: klevi on June 18, 2020, 12:07:27 pm
i need help when i run build a take error MODSound -pc -ignore_orphans  error2057

please i need help i have make your teddy bear shootable script it is work thank you but i want put music haow can i do it  have see tutorials but nothing please help
since the script is works then only the sound remains to be correctly added, literally convert your sound properly in audacity at unsigned 8bit PC or signed 16bit PC. Then put your sound in sound_assets/raw/sound/ there or make a folder there, and make sure that you properly call that sound it its soundalias, then just open launccher, click build mod ff and build sounds, and after building these go and grab your converted sound in raw/sound folder(if i remember correctly) and put it in your mod folder. Build your mod normally as you would do after that, FF and IWD and make sure you tick the new files in launcher on the right side, Done! krimp
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: GimmCity on July 23, 2020, 10:25:50 pm
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
can u tell me how ? or how i can make a door opens when i shoot the teddys... ?
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: cpt_johnson1 on July 24, 2020, 02:00:21 pm
can u tell me how ? or how i can make a door opens when i shoot the teddys... ?
Code Snippet
Plaintext


bears_complete() // Function which displays the text when both of the bears/triggers have been shot, no matter the order.
{
 
    door = getEnt("shootable_door", "targetname");  //this will be the door that opens
    pap_door_trigger = getEnt("pap_door", "targetname");
   
 play_sound_at_pos("door_slide_open", door.origin);
        //door MoveZ (200, 2);
        //door MoveY (100, 5);
        door MoveX (-100, 5);
    self.gate_is_moving = "true";
    door delete();
    pap_door_trigger Delete();
    flag_set( "zone3_to_pap_zone" );

    iPrintLn("You have unlocked a door");

 
        wait 1;
             
}



To open a door, you could use this script. Just fyi, the flag_set is if you want to activate a zone when the door opens.
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: GimmCity on July 25, 2020, 12:53:23 am
Code Snippet
Plaintext


bears_complete() // Function which displays the text when both of the bears/triggers have been shot, no matter the order.
{
 
    door = getEnt("shootable_door", "targetname");  //this will be the door that opens
    pap_door_trigger = getEnt("pap_door", "targetname");
   
 play_sound_at_pos("door_slide_open", door.origin);
        //door MoveZ (200, 2);
        //door MoveY (100, 5);
        door MoveX (-100, 5);
    self.gate_is_moving = "true";
    door delete();
    pap_door_trigger Delete();
    flag_set( "zone3_to_pap_zone" );

    iPrintLn("You have unlocked a door");

 
        wait 1;
             
}



To open a door, you could use this script. Just fyi, the flag_set is if you want to activate a zone when the door opens.
thanks ! but for what is this pap_door in the script ?
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: cpt_johnson1 on July 25, 2020, 02:24:12 am
thanks ! but for what is this pap_door in the script ?
Its the trigger for the door, which I used for a hintstring and to activate the zone. It may be kinda sloppy as I am not a scripter, but it works lol
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: GimmCity on July 25, 2020, 05:37:35 am
Its the trigger for the door, which I used for a hintstring and to activate the zone. It may be kinda sloppy as I am not a scripter, but it works lol
nice :Dcan u add me on discord ? maybe we can write there :D do u maybe know how i can import an animatet model in radiant that works, maybe an hanging cloth thats animated..... like in the map clinic  of evil..
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: cpt_johnson1 on July 25, 2020, 05:45:00 am
nice :Dcan u add me on discord ? maybe we can write there :D do u maybe know how i can import an animatet model in radiant that works, maybe an hanging cloth thats animated..... like in the map clinic  of evil..
Sorry but I can't help you there. I dont really know much about porting and animating stuff haha
Title: Re: Shootable teddy bears [UNORDERED] (for EE)
Post by: GimmCity on July 25, 2020, 06:04:29 am
Sorry but I can't help you there. I dont really know much about porting and animating stuff haha
ok thanks, no problem :Di added u on discord