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.
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();
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
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
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
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
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... ?
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 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..
nice :Dcan u add me on discord ? maybe we can write there 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