UGX-Mods

Call of Duty 5: World at War => Downloadable Items for Mappers => Custom Maps, Mods & Tools => Scripts => Topic started by: BluntStuffy on June 01, 2014, 12:09:13 pm

Title: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on June 01, 2014, 12:09:13 pm
This show's you how to make custom ammo, with three pre-made versions. This is what it looks like:

http://www.youtube.com/watch?v=U38FTOw5Oy0#ws (http://www.youtube.com/watch?v=U38FTOw5Oy0#ws)

Download the script and put it in your mods\mapname\maps\ folder. Next make these changes:
(make sure you edit in your mods folder and not in your RAW! )

-UPDATE-
The script is now updated with seperate triggers to buy the special ammo from. You can only buy the ammo at
these triggers. You are also able to set the price's for the ammo-type's, and for upgraded-special ammo..
All change's you can make are at the top of the _blst_custom_ammo.gsc in the main() function.. and you can also
add the guns you would like to have the effects there)
first set up the scripts.

(if you have the first version, only change the ammo_give() function in _zombiemode_weapons. And the stuff in mapname.gsc, and download the new scripts!)
-UPDATE-


In your _zombiemode_spawner.gsc

Right at the top of the file under this line:

Code Snippet
Plaintext
	#include maps\_zombiemode_utility;


add these 2 line's:

Code Snippet
Plaintext
	#include maps\_zombiemode_net;

#using_animtree( "generic_human" );



Next Search for:
Code Snippet
Plaintext
	zombie_damage( mod, hit_location, hit_origin, player )
{

   
Right below that add this:
Code Snippet
Plaintext
	shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );




Look a few line's down, and you'll see this:
Code Snippet
Plaintext
	if( !IsDefined( player ) )
{
return;
}

   
Right under that add this:
Code Snippet
Plaintext
		if( shock_ammo )
{
shock_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined( shock_tag ) )
{
network_safe_play_fx_on_tag( "shock_impact_fx", 3, level._effect["blst_shock_ammo"], self, shock_tag );
self playsound( "imp_tesla" );
}
}

if( flame_ammo )
{
if( !isdefined( self.flame_ammo_on_fire ) || isdefined( self.flame_ammo_on_fire ) && !self.flame_ammo_on_fire )
{
flame_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined(flame_tag))
{
network_safe_play_fx_on_tag( "flame_impact_fx", 3, level._effect["character_fire_pain_sm"], self, flame_tag );
}
self thread maps\_blst_custom_ammo::blst_flame_ammo( player );
}
}

if( explosive_ammo )
{
expl_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined( expl_tag))
{
network_safe_play_fx_on_tag( "expl_impact_fx", 3, level._effect["blst_expl_ammo"], self, expl_tag );
}
self maps\_blst_custom_ammo::blst_expl_ammo( hit_location );
}




Now do the same thing again, but this time search for:
Code Snippet
Plaintext
	zombie_damage_ads( mod, hit_location, hit_origin, player )
{
   
   
And right under that add:
Code Snippet
Plaintext
	shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );


   
And again a few line's down, look for this:
Code Snippet
Plaintext
	if( !IsDefined( player ) )
{
return;
}
   
Right under that add this:
Code Snippet
Plaintext
		if( shock_ammo )
{
shock_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined( shock_tag ) )
{
network_safe_play_fx_on_tag( "shock_impact_fx", 3, level._effect["blst_shock_ammo"], self, shock_tag );
self playsound( "imp_tesla" );
}
}

if( flame_ammo )
{
if( !isdefined( self.flame_ammo_on_fire ) || isdefined( self.flame_ammo_on_fire ) && !self.flame_ammo_on_fire )
{
flame_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined(flame_tag))
{
network_safe_play_fx_on_tag( "flame_impact_fx", 3, level._effect["character_fire_pain_sm"], self, flame_tag );
}
self thread maps\_blst_custom_ammo::blst_flame_ammo( player );
}
}

if( explosive_ammo )
{
expl_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined( expl_tag))
{
network_safe_play_fx_on_tag( "expl_impact_fx", 3, level._effect["blst_expl_ammo"], self, expl_tag );
}
self maps\_blst_custom_ammo::blst_expl_ammo( hit_location );
}





That's all in _spawner. Save and close.
Now in animscripts\death.gsc (in your mod folder!
if it's not there, copy it from raw\animscripts\ to your mods\mapname\animscripts\ folder (just create that..)

Right at the top of the first function, under this line:
Code Snippet
Plaintext
	self flamethrower_stop_shoot(); 
   
Add this part:
Code Snippet
Plaintext
	wpn_check = maps\_blst_custom_ammo::blst_shock( self.damageweapon, self.damagemod );					// Shock Ammo
if( wpn_check && level.zombie_vars["zombie_insta_kill"] == 0 )
{
self.deathanim = random( level._zombie_tesla_death[self.animname] );
Playfxontag (level._effect["tesla_shock_eyes"], self, "J_Eyeball_LE" );
Playfxontag (level._effect["tesla_shock"], self, "J_SpineUpper" );
}

wpn_check = maps\_blst_custom_ammo::blst_flame( self.damageweapon, self.damagemod ); // Flame Ammo
if( wpn_check && level.zombie_vars["zombie_insta_kill"] == 0 )
{
if( !isdefined( self.is_on_fire ) || isdefined( self.is_on_fire ) && !self.is_on_fire )
{
self thread flame_death_fx();
}
}

wpn_check = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, self.damagemod ); // Explosive Ammo
if( wpn_check && level.zombie_vars["zombie_insta_kill"] == 0 )
{
expl_anim = maps\_blst_custom_ammo::death_anim_yaw( self.damageyaw );
self.deathanim = expl_anim;
}

Save and close..


Now open up your _zombiemode_weapons.gsc and look for the ammo_give() function. replace that entire function with this one, and the new one attached:

Code Snippet
Plaintext
ammo_give( weapon, also_has_upgrade )
{
// We assume before calling this function we already checked to see if the player has this weapon...

if( !isDefined( also_has_upgrade ) )
{
also_has_upgrade = false;
}

// Should we give ammo to the player
give_ammo = false;

// Check to see if ammo belongs to a primary weapon
if( weapon != "fraggrenade" && weapon != "stielhandgranate" && weapon != "molotov" )
{
if( isdefined( weapon ) ) 
{
// get the max allowed ammo on the current weapon
stockMax = WeaponMaxAmmo( weapon );
if( also_has_upgrade )
{
stockMax += WeaponMaxAmmo( weapon+"_upgraded" );
}

// Get the current weapon clip count
clipCount = self GetWeaponAmmoClip( weapon );

currStock = self GetAmmoCount( weapon );

// compare it with the ammo player actually has, if more or equal just dont give the ammo, else do
if( ( currStock - clipcount ) >= stockMax )
{
give_ammo = false;
}
else
{
give_ammo = true; // give the ammo to the player
}
}
}
else
{
// Ammo belongs to secondary weapon
if( self has_weapon_or_upgrade( weapon ) )
{
// Check if the player has less than max stock, if no give ammo
if( self getammocount( weapon ) < WeaponMaxAmmo( weapon ) )
{
// give the ammo to the player
give_ammo = true;
}
}
}

weapon_test = self getcurrentweapon();
if ( give_ammo && WeaponInventoryType( weapon_test ) == "altmode" )
{
alt_ammo = check_if_is_defined( weapon_test );
if ( alt_ammo && self.alt_message_count < level.alt_message_count_max )
{
self.alt_message_count ++;
self iprintlnbold( level.hint_alt_buy_wall );
}
}

special_ammo = check_if_is_defined( weapon );


if( give_ammo && !special_ammo )
{
self playsound( "cha_ching" );
self GivemaxAmmo( weapon );
if( also_has_upgrade )
{
self GiveMaxAmmo( weapon+"_upgraded" );
}
return true;
}

if( give_ammo && special_ammo || give_ammo && special_ammo || !give_ammo && WeaponInventoryType( weapon_test ) == "altmode" )
{
if ( self.alt_message_count < level.alt_message_count_max)
{
self.alt_message_count ++;
self iprintlnbold( level.hint_primary_buy_wall );
}
return false;
}

if( !give_ammo )
{
return false;
}
}

check_if_is_defined( weapon )
{
if(isdefined(level.shock_ammo[weapon]))
{
return true;
}

else if(isdefined(level.flame_ammo[weapon]))
{
return true;
}

else if(isdefined(level.expl_ammo[weapon]))
{
return true;
}

else
{
return false;
}
}



Save and close..



Last thing, in your mapname.gsc:

Look for this line:
Code Snippet
Plaintext
	maps\_zombiemode::main();
   
Right ABOVE that line, add this one:

Code Snippet
Plaintext
	maps\_blst_custom_ammo::custom_ammo_precache();
   

And UNDER the "_zombiemode::main() line add:

Code Snippet
Plaintext
	thread maps\_blst_custom_ammo::main();
thread maps\_custom_ammo_buy::main();



Now when you open up the _blst_custom_ammo.gsc you see the main() function, in there you can change the price for all ammo-type's
and add weapons. The weapon line's look like this:

Code Snippet
Plaintext
	add_weapon( "zombie_shotgun"		, "Trenchgun - Shock"		, "shock"	, false );
add_weapon( "zombie_thompson_shock" , "Thompson - Shock" , "shock" , true  );

Here you can simply add / remove weapons for each ammo-type.

Code Snippet
Plaintext
	// 	Syntax: add_weapon( "NAME_OF_WEAPON_FILE", "DISPLAY NAME", "AMMO_TYPE", "IS UPGRADED VERSION" )	

display_name: the name of the weapon used in the hinst's to the player. Just make that up yourself, whatever you want..
ammo_type: can be "shock" "flame" or "expl"
is upgraded: set to true if this is a pap'ed gun, to increase ammo price's. otherwise set to false
   
Easy as that!



In radiant make the triggers to buy ammo from a trigger_use, with the kvp:

Code Snippet
Plaintext
 targetname - elemental_ammo 



If you find any bugs / problems let me know, otherwise enjoy!!
And if used please give credit!





Setting up an alt-weapon:

The easiest thing to do is just copy the weapon-file, and have the exact same gun-model as an alt-weapon.. But you
can go all out with this, and make it have attachments a different cammo or even just a completely different gun.
Doesn't matter, as long as you set up the weapon file's correctly:

Let's asume we just copy the zombie_thompson weapon file, and rename that zombie_thompson_shock.
We want the shock thompson to be the alt-weapon for the normal thompson, the setup:

First open the normal thompson weapon file, and make the changes below:
Code Snippet
Plaintext
altweapon          -          zombie_thompson_shock
inventorytype     -          primary
ammoname        -          thompson (doesn't really matter as long as it's unique)
clipname            -          thompson (same as above)
altdroptime        -          the time for the drop animation when switching to alt-weapon
altraisetime       -          the time for the raise animation when switching from alt-weapon
altdropanim       -          viewmodel_thomspson_putaway_fast (for example)
altraiseanim       -          viewmodel_thomspson_pullout_fast
dpadicon            -          copy it from the hudicon next to it

Now open the zombie_thompson_shock weapon file, and change this:
Code Snippet
Plaintext
modename		   -          Shock Ammo (optional) 
altweapon    -          zombie_thompson
inventorytype    -          altmode

ammoname          -          thompson_shock (doesn't really matter as long as it's unique)
clipname              -          thompson_shock (same as above)
altdroptime           -          the time for the drop animation when switching to alt-weapon
altraisetime          -          the time for the raise animation when switching from alt-weapon
altdropanim          -          viewmodel_thomspson_putaway_fast (for example)
altraiseanim          -          viewmodel_thomspson_pullout_fast
dpadicon              -          copy it from the hudicon next to it


just make sure the alt-weapon is also loaded in your mod.csv / _zombiemode_weapons / and dlc3_code and this should
work fine.




Thanks, thezombiekilla6 for testing it with me and finding some bugs!



Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: Dust on June 01, 2014, 09:10:02 pm
Wow good tutorial. Will definitely try this out
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: pashan on June 02, 2014, 02:29:46 am
is it like a drop or is it there throughout the whole game
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: Dust on June 02, 2014, 03:36:07 am
is it like a drop or is it there throughout the whole game

he shows it in the video. You specify what weapon you want to have the elemental effects on in the script, and when you use that weapon it will use the effects

Also is it possible to have different types of ammo in a gun at one time. Similar to extinction, how if you have shock ammo you use that first then when that runs out it goes back to normal ammo and you can refill the shock ammo by a max ammo. Or is it not possible in waw?
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: shippuden1592 on June 02, 2014, 05:26:41 am
This looks fantastic, thanks for the tutorial.

Just one question is the same injury that would cause the weapon or is increased by the custom ammo type?
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: NaviLlicious on June 02, 2014, 06:28:41 am
This looks fantastic, thanks for the tutorial.

Just one question is the same injury that would cause the weapon or is increased by the custom ammo type?
I would assume you can set the damage of the weapon In the weapon file
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: Zombiejelly on June 02, 2014, 08:08:55 am
very nice tutorial, thank you for sharing this
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on June 02, 2014, 08:38:05 am
is it like a drop or is it there throughout the whole game

No right now you put the name's of the guns you want to have the effects in the script, and they have it the entire game.
I allready thought of also making a version as a powerup-drop, wich then give's random special-ammo to the players for 30 seconds..

Quote
Also is it possible to have different types of ammo in a gun at one time. Similar to extinction, how if you have shock ammo you use that first then when that runs out it goes back to normal ammo and you can refill the shock ammo by a max ammo. Or is it not possible in waw?

You can do something kind off like that, by making it alt-weapons like the grenade-launcher is. You will probably need to change some stuff in _zombiemode_weapons if you want to be able to buy ammo off the wall for the alt-weapons.. If you're interested in making this happen, i can help you out. Allready got a simulair setup for my Greenhouse map.

Quote
Just one question is the same injury that would cause the weapon or is increased by the custom ammo type?

No, NaviLlicious is right. I decided not to make it do any extra damage in the script. Just set the damage for the weapon in the weapon file, and that's the damage to gun does.. No increase in the script.. (it has that effect the entire game anyway)
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: HitmanVere on June 02, 2014, 10:52:07 am
Can I make custom perk, that applies, for example, shock ammo to every bullet gun? Would it be too much pain to script?
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: Dust on June 02, 2014, 11:00:23 am
You can do something kind off like that, by making it alt-weapons like the grenade-launcher is. You will probably need to change some stuff in _zombiemode_weapons if you want to be able to buy ammo off the wall for the alt-weapons.. If you're interested in making this happen, i can help you out. Allready got a simulair setup for my Greenhouse map.

Ya if you could show me a sample script on how i would go about that, that would be great.
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on June 02, 2014, 01:37:14 pm
Can I make custom perk, that applies, for example, shock ammo to every bullet gun? Would it be too much pain to script?

Easiest way to do that i think is just add a check to the function's in the _custom_ammo script that checks if the player has the perk. If it doesn't have the perk, make it return false. Then you wouldn't have to make any other changes to the script or the way it works..


Ya if you could show me a sample script on how i would go about that, that would be great.

First post updated with a little script change for buying alt-weapon ammo. It's been a while since i did it for greenhouse and i actually have seperate triggers in my map for buying alt-ammo. But i did some quick testing with this and it seems to work fine  ::)
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: Dust on June 02, 2014, 02:16:39 pm
Just tested it and it works but whenever im not using the shock ammo it still drains the ammo of it and the normal ammo at the same time. Which makes it pretty pointless to have both ammos. Also how can i make the elemental ammo cost a different price than the normal ammo?
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: HitmanVere on June 02, 2014, 02:27:30 pm
Easiest way to do that i think is just add a check to the function's in the _custom_ammo script that checks if the player has the perk. If it doesn't have the perk, make it return false. Then you wouldn't have to make any other changes to the script or the way it works..

Thanks, will try this
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on June 02, 2014, 02:48:57 pm
Just tested it and it works but whenever im not using the shock ammo it still drains the ammo of it and the normal ammo at the same time. Which makes it pretty pointless to have both ammos. Also how can i make the elemental ammo cost a different price than the normal ammo?

You probably forgot to change a ammoname and or clipname? If they are the same the weapons use the same ammo-stock.
For changing the price it would require some more scripting. This setup isn't ideal for that since it give's ammo to both weapons at once (primary and alt)
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: Dust on June 02, 2014, 03:00:08 pm
You probably forgot to change a ammoname and or clipname? If they are the same the weapons use the same ammo-stock.
For changing the price it would require some more scripting. This setup isn't ideal for that since it give's ammo to both weapons at once (primary and alt)

Ah that was it i forgot to change the ammoname and clipname. Also you know a good place to start to script the different prices?
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on June 02, 2014, 03:16:01 pm
Ah that was it i forgot to change the ammoname and clipname. Also you know a good place to start to script the different prices?

Kind of depends, do you want to just buy the alt-ammo at the wall-weapon trigger? ->go back to the stock function of the ammo_give() ) and you prob need to modify the last part of the weapon_spawn_think() function to check for an alt-weapon and adjust the price in there.

You could also make new triggers on different locations that only provide the players with alt-ammo. In that case just start a small script from scratch..

Lemme know if you need help with the actual scripting..

Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: pashan on June 02, 2014, 03:52:18 pm
could you make another tut on how to make it a power drop. like when after the player picks it up the gun which they are holding becomes fire/shock/explosive for a limited time?
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: shippuden1592 on June 02, 2014, 04:18:56 pm
No, NaviLlicious is right. I decided not to make it do any extra damage in the script. Just set the damage for the weapon in the weapon file, and that's the damage to gun does.. No increase in the script.. (it has that effect the entire game anyway)


That's cool brother, thanks for everything.

Greetings!!
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: Dust on June 02, 2014, 05:13:07 pm
Kind of depends, do you want to just buy the alt-ammo at the wall-weapon trigger? ->go back to the stock function of the ammo_give() ) and you prob need to modify the last part of the weapon_spawn_think() function to check for an alt-weapon and adjust the price in there.

You could also make new triggers on different locations that only provide the players with alt-ammo. In that case just start a small script from scratch..

Lemme know if you need help with the actual scripting..

So I been trying ever since my last post to get this working. I did a separate trigger that will control all of the elemental ammo buys. It works up to a degree, when i press f to buy elemental ammo without a elemental ammo it says "You cannot buy Elemental Ammo for this Weapon". then when i actually have a elemental weapon it does nothing when i press f. you mind taking a look? This is my first real attempt at scripting something like this, so some stuff may be weird.

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;
init()
{
thread elemental_trigger();
}
elemental_trigger()
{
trig = getent("elemental_ammo","targetname");
trig setcursorhint("HINT_NOICON");
trig sethintstring("Press and Hold &&1 to buy Elemental Ammo [Cost:2000]");
trig waittill("trigger",player);
player thread check_for_elemental_weapon();
}
check_for_elemental_weapon()
{
player = undefined;
weapon = undefined();
altweapon =  WeaponAltWeaponName( weapon ); // custom ammo buy
if( altweapon != "none" )
{   

altweapon =  WeaponAltWeaponName( weapon ); // custom ammo buy
if( altweapon != "none" )
{
player GivemaxAmmo( altweapon );
}
    if(player.score > 1999)
     {
player maps\_zombiemode_score::minus_to_player_score(2000);
player playsound( "cha_ching" );
trig = getent("elemental_ammo","targetname");
trig disable_trigger();
wait 1;
trig enable_trigger();

if( altweapon == "none")
{
self iprintlnbold("You cannot buy Elemental Ammo for this Weapon");
}
}
}
}
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on June 02, 2014, 05:26:34 pm
So I been trying ever since my last post to get this working. I did a separate trigger that will control all of the elemental ammo buys. It works up to a degree, when i press f to buy elemental ammo without a elemental ammo it says "You cannot buy Elemental Ammo for this Weapon". then when i actually have a elemental weapon it does nothing when i press f. you mind taking a look? This is my first real attempt at scripting something like this, so some stuff may be weird.

Np, i have a look a little later. Allready in the middle of something now..

could you make another tut on how to make it a power drop. like when after the player picks it up the gun which they are holding becomes fire/shock/explosive for a limited time?

I'll also have a look at this one, that will be sometime later this week though..
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: tudark on June 02, 2014, 06:52:04 pm
Hi Bluntstuffy , thanks for  the tutorials . The tutorials you've been putting out are great and its good to see somebody sharing the good stuff.
On this tutorial I have followed but have a few problems, hope you can help.  The explosive gun works with the effects but the zombie don't blow away.
The tesla kills them  and I hear the noise just no effects or the death.
fire works perfect.

I did follow tut , but was lost to find the death .gsc . the only one I found was in raw /animscripts.
I just copied that into my mod /mapname/maps and edited it as you said. thanks for any help in advance.

Post Merge: June 02, 2014, 06:53:40 pm
I meant fx`s
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: Dust on June 02, 2014, 06:55:36 pm
Hi Bluntstuffy , thanks for  the tutorials . The tutorials you've been putting out are great and its good to see somebody sharing the good stuff.
On this tutorial I have followed but have a few problems, hope you can help.  The explosive gun works with the effects but the zombie don't blow away.
The tesla kills them  and I hear the noise just no effects or the death.
fire works perfect.

I did follow tut , but was lost to find the death .gsc . the only one I found was in raw /animscripts.
I just copied that into my mod /mapname/maps and edited it as you said. thanks for any help in advance.

Post Merge: June 02, 2014, 06:53:40 pm
I meant fx`s

your suppose to copy the death.gsc into mapname/animscripts, so create a new folder in your mods folder and name it animscripts then paste that in there and edit it
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: tudark on June 02, 2014, 09:26:37 pm
Hey ,thanks very much for your help  will try later.
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on June 06, 2014, 07:28:58 pm
The first post is now updated with a new version of the script. You can now place triggers in radiant where the players buy their special ammo from. The players can only buy the special ammo at these triggers, and they can't buy normal ammo there..
You can change the price's for each ammo type now too.

I would recommend to the people that might have the first version to install this one (sorry for that..)
This is tested propperly by thezombiekilla6 (thanks for that!) and me, and it should work without any issue's..

Otherwise let me know  :)
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: OfficialMT22 on August 28, 2014, 02:10:18 am
FIXED every question i had .... THANKS FOR THIS

Double Post Merge: August 28, 2014, 04:51:14 pm
The first post is now updated with a new version of the script. You can now place triggers in radiant where the players buy their special ammo from. The players can only buy the special ammo at these triggers, and they can't buy normal ammo there..
You can change the price's for each ammo type now too.

I would recommend to the people that might have the first version to install this one (sorry for that..)
This is tested propperly by thezombiekilla6 (thanks for that!) and me, and it should work without any issue's..

Otherwise let me know  :)

anyway to script a hud icon for different types of ammo..... I tried but image wont show next to numbers... I also attached the images I personally would like to use for shock, flame, explosive

If you could do this before I can figure it out which will prob be never THAN THANKS!!!


EDIT: got the icon to show up on hud but it show up for everything and everygun
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on August 31, 2014, 09:08:42 pm
anyway to script a hud icon for different types of ammo..... I tried but image wont show next to numbers... I also attached the images I personally would like to use for shock, flame, explosive

If you could do this before I can figure it out which will prob be never THAN THANKS!!!

Here's what i put together for you, it's using a HUD element that will Always be on-screen when you wield a 'special-ammo weapon' and not fade away like the ammo counter does..

Open the _blst_custom_ammo.gsc and at the top, below the line:

Code Snippet
Plaintext
#include maps\_zombiemode_utility;

add this line:

Code Snippet
Plaintext
#include maps\_hud_util;



Now look for this line:

Code Snippet
Plaintext
	level.expl_ammo_sound = false;

And below that add:

Code Snippet
Plaintext
	PrecacheShader( "specialty_juggernaut_zombies" );
PrecacheShader( "specialty_fastreload_zombies" );
PrecacheShader( "specialty_doubletap_zombies" );



Next look fot the line:

Code Snippet
Plaintext
	players[i].alt_message_count = 0;

and below that one add:

Code Snippet
Plaintext
	players[i] thread alt_ammo_hud();	



Now go to the bottom of the file and add this new function:

Code Snippet
Plaintext
alt_ammo_hud()
{
self endon( "death" );
self endon( "disconnect" );

self.hud_set = "none";

while(1)
{
ammo_hud = undefined;
shader = undefined;
gun = self getcurrentweapon();

if(isdefined(level.shock_ammo[gun]))
{
ammo_hud = "shock";
shader = "specialty_juggernaut_zombies";
}

else if(isdefined(level.flame_ammo[gun]))
{
ammo_hud = "flame";
shader = "specialty_fastreload_zombies";
}

else if(isdefined(level.expl_ammo[gun]))
{
ammo_hud = "expl";
shader = "specialty_quickrevive_zombies";
}

else
{
ammo_hud = "none";
}

if( self.hud_set != ammo_hud )
{
self.hud_set = ammo_hud;

if( isdefined( self.custom_hud[ "ammo" ] ) )
{
self.custom_hud[ "ammo" ] destroy_hud();
self.custom_hud[ "ammo" ] = undefined;
}

self.ammo_hud = NewClientHudElem( self );
self.ammo_hud.foreground = true;
self.ammo_hud.sort = 1;
self.ammo_hud.hidewheninmenu = false;
self.ammo_hud.alignX = "right";
self.ammo_hud.alignY = "bottom";
self.ammo_hud.horzAlign = "right";
self.ammo_hud.vertAlign = "bottom";
self.ammo_hud.x = self.ammo_hud.x - 5;
self.ammo_hud.y = self.ammo_hud.y - 95;
self.ammo_hud.alpha = 1;
self.ammo_hud SetShader( shader, 45, 45 );

self.custom_hud[ "ammo" ] = self.ammo_hud;
}
wait 0.2;
}
}



NOTE: I'm using the perk-icons as place-holders here, replace the
"specialty_juggernaut_zombies"
"specialty_fastreload_zombies"
"specialty_doubletap_zombies"

with the name's of the shaders you want to use (there's 2 entry's of both!), also add the materials to your mod.csv like this:

Code Snippet
Plaintext
material,MATERIAL_NAME

You change the position of the shader by changing the numbers in these lines:

Code Snippet
Plaintext
	self.ammo_hud.x = self.ammo_hud.x - 5; 
self.ammo_hud.y = self.ammo_hud.y - 95;

And you can change the size of the shader by changing the numbers in this line:

Code Snippet
Plaintext
	self.ammo_hud SetShader( shader, 45, 45 );


That should be all.
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: OfficialMT22 on August 31, 2014, 09:50:58 pm
thanks... when i add to my map ill let you know if it worked :D
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: Centric on September 20, 2014, 09:27:30 pm
I've tried everything I could think of to make this work, but no matter what it doesn't. I'm trying to make a spas12 with flame but in game in still says "spas 12" and shoots normal rounds. Even the weapons you added to the script don't work. Could you put your scripts up for download so I could get this to work? I'm obviously doing something wrong.
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on September 23, 2014, 04:53:38 pm
I've tried everything I could think of to make this work, but no matter what it doesn't. I'm trying to make a spas12 with flame but in game in still says "spas 12" and shoots normal rounds. Even the weapons you added to the script don't work. Could you put your scripts up for download so I could get this to work? I'm obviously doing something wrong.

And you did put the scripts in your MOD folder, and selected them in the compile window when compiling your MOD?
Otherwise post the edited scripts in a code-box or PM me..
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: iBarnett on September 27, 2014, 06:31:58 pm
Question on the triggers in radiant. Are the triggers specific to ammo types or they just to buy ammo for the specific gun your holding. If the triggers are for specific ammo what are the kvp's for the 3 different types?
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on September 27, 2014, 06:44:24 pm
Question on the triggers in radiant. Are the triggers specific to ammo types or they just to buy ammo for the specific gun your holding. If the triggers are for specific ammo what are the kvp's for the 3 different types?

They work for the gun your holding, there's not a seperate trigger for each ammo-type.
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: iBarnett on September 27, 2014, 06:47:38 pm
Question on the triggers in radiant. Are the triggers specific to ammo types or they just to buy ammo for the specific gun your holding. If the triggers are for specific ammo what are the kvp's for the 3 different types?
So i'm also getting this error when trying to launch my map now
bad sentax: shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );

that's word for word what you have . why is this not working??
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on September 27, 2014, 06:50:14 pm
So i'm also getting this error when trying to launch my map now
bad sentax: shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );

that's word for word what you have . why is this not working??

Post the entire function with that line in it in a code-box, so i can have a look at it..
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: iBarnett on September 27, 2014, 06:58:01 pm
So its in my _spawners.gsc

first section with that line of code
Code Snippet
Plaintext
zombie_damage( mod, hit_location, hit_origin, player )
shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );

{
if( is_magic_bullet_shield_enabled( self ) )
{
return;
}

//ChrisP - 12/8 - no points for killing gassed zombies!
player.use_weapon_type = mod;
if(isDefined(self.marked_for_death))
{
return;
}

if( !IsDefined( player ) )
{
return;
}
if( shock_ammo )
{
shock_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined( shock_tag ) )
{
network_safe_play_fx_on_tag( "shock_impact_fx", 3, level._effect["blst_shock_ammo"], self, shock_tag );
self playsound( "imp_tesla" );
}
}

if( flame_ammo )
{
if( !isdefined( self.flame_ammo_on_fire ) || isdefined( self.flame_ammo_on_fire ) && !self.flame_ammo_on_fire )
{
flame_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined(flame_tag))
{
network_safe_play_fx_on_tag( "flame_impact_fx", 3, level._effect["character_fire_pain_sm"], self, flame_tag );
}
self thread maps\_blst_custom_ammo::blst_flame_ammo( player );
}
}

if( explosive_ammo )
{
expl_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined( expl_tag))
{
network_safe_play_fx_on_tag( "expl_impact_fx", 3, level._effect["blst_expl_ammo"], self, expl_tag );
}
self maps\_blst_custom_ammo::blst_expl_ammo( hit_location );
}

if( self zombie_flame_damage( mod, player ) )
{
if( self zombie_give_flame_damage_points() )
{
player maps\_zombiemode_score::player_add_points( "damage", mod, hit_location, self enemy_is_dog() );
}
}
else if( self maps\_zombiemode_tesla::is_tesla_damage( mod ) )
{
self maps\_zombiemode_tesla::tesla_damage_init( hit_location, hit_origin, player );
return;
}
else
{
player maps\_zombiemode_score::player_add_points( "damage", mod, hit_location, self enemy_is_dog() );
}

if ( mod == "MOD_GRENADE" || mod == "MOD_GRENADE_SPLASH" )
{
if ( isdefined( player ) && isalive( player ) )
{
self DoDamage( level.round_number + randomintrange( 100, 500 ), self.origin, player);
}
else
{
self DoDamage( level.round_number + randomintrange( 100, 500 ), self.origin, undefined );
}
}
else if( mod == "MOD_PROJECTILE" || mod == "MOD_EXPLOSIVE" || mod == "MOD_PROJECTILE_SPLASH" || mod == "MOD_PROJECTILE_SPLASH")
{
if ( isdefined( player ) && isalive( player ) )
{
self DoDamage( level.round_number * randomintrange( 0, 100 ), self.origin, player);
}
else
{
self DoDamage( level.round_number * randomintrange( 0, 100 ), self.origin, undefined );
}
}
else if( mod == "MOD_ZOMBIE_BETTY" )
{
if ( isdefined( player ) && isalive( player ) )
{
self DoDamage( level.round_number * randomintrange( 100, 200 ), self.origin, player);
}
else
{
self DoDamage( level.round_number * randomintrange( 100, 200 ), self.origin, undefined );
}
}

//AUDIO Plays a sound when Crawlers are created
if( IsDefined( self.a.gib_ref ) && (self.a.gib_ref == "no_legs") && isalive( self ) )
{
if ( isdefined( player ) )
{
rand = randomintrange(0, 100);
if(rand < 10)
{
index = maps\_zombiemode_weapons::get_player_index(player);
plr = "plr_" + index + "_";
player thread create_and_play_dialog( plr, "vox_crawl_spawn", 0.25, "resp_cspawn" );
}
}
}
else if( IsDefined( self.a.gib_ref ) && ( (self.a.gib_ref == "right_arm") || (self.a.gib_ref == "left_arm") ) )
{
if( self.has_legs && isalive( self ) )
{
if ( isdefined( player ) )
{
rand = randomintrange(0, 100);
if(rand < 3)
{
index = maps\_zombiemode_weapons::get_player_index(player);
plr = "plr_" + index + "_";
player thread create_and_play_dialog( plr, "vox_shoot_limb", 0.25 );
}
}
}
}
self thread maps\_zombiemode_powerups::check_for_instakill( player );
}

second place it appears
Code Snippet
Plaintext
zombie_damage_ads( mod, hit_location, hit_origin, player )
shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );

{
if( is_magic_bullet_shield_enabled( self ) )
{
return;
}

player.use_weapon_type = mod;
if( !IsDefined( player ) )
{
return;
}
if( shock_ammo )
{
shock_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined( shock_tag ) )
{
network_safe_play_fx_on_tag( "shock_impact_fx", 3, level._effect["blst_shock_ammo"], self, shock_tag );
self playsound( "imp_tesla" );
}
}

if( flame_ammo )
{
if( !isdefined( self.flame_ammo_on_fire ) || isdefined( self.flame_ammo_on_fire ) && !self.flame_ammo_on_fire )
{
flame_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined(flame_tag))
{
network_safe_play_fx_on_tag( "flame_impact_fx", 3, level._effect["character_fire_pain_sm"], self, flame_tag );
}
self thread maps\_blst_custom_ammo::blst_flame_ammo( player );
}
}

if( explosive_ammo )
{
expl_tag = maps\_blst_custom_ammo::hit_tag( hit_location );
if( isdefined( expl_tag))
{
network_safe_play_fx_on_tag( "expl_impact_fx", 3, level._effect["blst_expl_ammo"], self, expl_tag );
}
self maps\_blst_custom_ammo::blst_expl_ammo( hit_location );
}


if( self zombie_flame_damage( mod, player ) )
{
if( self zombie_give_flame_damage_points() )
{
player maps\_zombiemode_score::player_add_points( "damage_ads", mod, hit_location );
}
}
else if( self maps\_zombiemode_tesla::is_tesla_damage( mod ) )
{
self maps\_zombiemode_tesla::tesla_damage_init( hit_location, hit_origin, player );
return;
}
else
{
player maps\_zombiemode_score::player_add_points( "damage_ads", mod, hit_location );
}

self thread maps\_zombiemode_powerups::check_for_instakill( player );
}

zombie_give_flame_damage_points()
{
if( GetTime() > self.flame_damage_time )
{
self.flame_damage_time = GetTime() + level.zombie_vars["zombie_flame_dmg_point_delay"];
return true;
}

return false;
}

zombie_flame_damage( mod, player )
{
if( mod == "MOD_BURNED" )
{
self.moveplaybackrate = 0.8;

if( !IsDefined( self.is_on_fire ) || ( Isdefined( self.is_on_fire ) && !self.is_on_fire ) )
{
self thread damage_on_fire( player );
}

do_flame_death = true;
dist = 100 * 100;
ai = GetAiArray( "axis" );
for( i = 0; i < ai.size; i++ )
{
if( IsDefined( ai[i].is_on_fire ) && ai[i].is_on_fire )
{
if( DistanceSquared( ai[i].origin, self.origin ) < dist )
{
do_flame_death = false;
break;
}
}
}

if( do_flame_death )
{
self thread animscripts\death::flame_death_fx();
}

return true;
}

return false;
}


hope that helps
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on September 27, 2014, 07:16:11 pm
cange this:

Code Snippet
Plaintext
zombie_damage( mod, hit_location, hit_origin, player )
shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );

{

into this:

Code Snippet
Plaintext
zombie_damage( mod, hit_location, hit_origin, player )
{
shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );


And do the same for the other function
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: iBarnett on September 27, 2014, 07:19:08 pm
cange this:

Code Snippet
Plaintext
zombie_damage( mod, hit_location, hit_origin, player )
shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );

{

into this:

Code Snippet
Plaintext
zombie_damage( mod, hit_location, hit_origin, player )
{
shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );


And do the same for the other function
get rid if that { at the end as well?

Double Post Merge: September 27, 2014, 07:26:46 pm
get rid if that { at the end as well?
because it now gives me
error bad sentax {

Double Post Merge: September 27, 2014, 07:32:15 pm
get rid if that { at the end as well?

Double Post Merge: September 27, 2014, 07:26:46 pm
because it now gives me
error bad sentax {
Ok so it was that last { that was causing the bad sentax

Everything works now map launches. THANKS!! glad you took the time to help me through it! +1
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: BluntStuffy on September 27, 2014, 07:32:45 pm
Yes, NOT like this:

Code Snippet
Plaintext
zombie_damage( mod, hit_location, hit_origin, player )
{
shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );

{



but like this:

Code Snippet
Plaintext
zombie_damage( mod, hit_location, hit_origin, player )
{
shock_ammo = maps\_blst_custom_ammo::blst_shock( self.damageweapon, mod );
flame_ammo = maps\_blst_custom_ammo::blst_flame( self.damageweapon, mod );
explosive_ammo = maps\_blst_custom_ammo::blst_explosive( self.damageweapon, mod, self );

Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: iBarnett on September 27, 2014, 07:45:19 pm
Ya super glad i came across this script you posted. I was having troubles with adding blops weapons but not being able to buy wall ammo. but i figured a neat way to add this in to make it all work out.
thanks again.

Double Post Merge: September 27, 2014, 09:39:43 pm
just thought i'd post a pic of a cool little machine for buying the custom ammo.
(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi62.tinypic.com%2Fm8i3hh.jpg&hash=211c4243403edca21349f31f39e9b0aaae0b37ef)
thanks again for the scripts Blunt!! will give credit when map is released.
Title: Re: [TUT] Adding custom ammo: Flame / Shock and Explosive
Post by: OfficialMT22 on October 01, 2014, 06:38:21 pm
Question on the triggers in radiant. Are the triggers specific to ammo types or they just to buy ammo for the specific gun your holding. If the triggers are for specific ammo what are the kvp's for the 3 different types?

the way i got the different ammo triggers to work... Atleast i think they worked is " I split the ammos up in the _custom_ammo_buy.gsc and made different files for each ammo." I have attached some demo files for you to play with, but make sure you have backup of your original files and dont forget to add this line to your nazi_zombie_{MAP_NAME}.gsc

UNDER
Code Snippet
Plaintext
	/*--------------------
ZOMBIE MODE
----------------------*/
ADD
Code Snippet
Plaintext
	thread maps\_custom_ammo_fire_buy::main();
thread maps\_custom_ammo_shock_buy::main();

dont forget to change the triggers in your map to the names in the files posted
Code Snippet
Plaintext
	trig = getentarray("fire_ammo","target");