UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: Joeycx on May 24, 2018, 06:51:14 am

Title: Upgraded Weapon Problem
Post by: Joeycx on May 24, 2018, 06:51:14 am
Hi! I'm wondering since i have an upgraded_upgraded weapon, that can i make it so i can buy wall ammo off the wall for an upgraded_upgraded weapon, and to change the pack a punch price for an upgraded_upgraded weapon to be different from 5000? Also can that weapon be removed from the mystery box once it has been double pap, to prevent a useless weapon in a mystery box? If anyone could help me, that would be appreciated :)
Title: Re: Upgraded Weapon Problem
Post by: Tim Smith on May 27, 2018, 06:32:21 pm
I can't really remember who helped me to do it, but make cents talked about the normal in here. Maybe you can just edit it to be _upgraded_upgraded in the script.

https://www.ugx-mods.com/forum/index.php/topic,8396.msg91080.html#msg91080 (https://www.ugx-mods.com/forum/index.php/topic,8396.msg91080.html#msg91080)
Title: Re: Upgraded Weapon Problem
Post by: Harry Bo21 on May 28, 2018, 04:02:58 am
Hi! I'm wondering since i have an upgraded_upgraded weapon, that can i make it so i can buy wall ammo off the wall for an upgraded_upgraded weapon, and to change the pack a punch price for an upgraded_upgraded weapon to be different from 5000? Also can that weapon be removed from the mystery box once it has been double pap, to prevent a useless weapon in a mystery box? If anyone could help me, that would be appreciated :)
Title: Re: Upgraded Weapon Problem
Post by: Joeycx on May 28, 2018, 05:07:25 am
Thanks tim, but i'm looking for help with an upgraded_upgraded weapon instead of _upgraded weapon only lol.
Title: Re: Upgraded Weapon Problem
Post by: Tim Smith on May 30, 2018, 10:05:41 am



3 words changed the hole meaning, read it again. I was talking in script, already know that he has the weapons done already.
Title: Re: Upgraded Weapon Problem
Post by: BluntStuffy on May 30, 2018, 11:17:51 am
I have an old topic on zombiemodding.com where it tells you all the stuff you meed to change for wall-buy, ammo, hasweapon checks etc. You would have to look for it. Search for my username ( also BluntStuffy and try something like _upgraded_upgraded )
If you cant find it i can try and look for it tonight/tomorrow
Title: Re: Upgraded Weapon Problem
Post by: Joeycx on May 30, 2018, 01:17:23 pm
I have an old topic on zombiemodding.com where it tells you all the stuff you meed to change for wall-buy, ammo, hasweapon checks etc. You would have to look for it. Search for my username ( also BluntStuffy and try something like _upgraded_upgraded )
If you cant find it i can try and look for it tonight/tomorrow

OMFG thank you so much. I've been trying to find a solution for this for ages. But i also have 2 questions regarding this.
1: In your post you said something about alt ammo, is alt ammo purchasable from the original weapon trigger? (ex: buys type 99, upgrades it, it gets gl attachment, buys type 99 upgraded ammo)

2: the hintstring don't seem to update from the script. The prices are 5000 for _upgraded_upgraded ammo but buying a gun, it just lists " 500(gun price) || 350 (ammo price) || 4500 (upgraded ammo price " instead of updating _upgraded price and adding _upgraded_upgraded's price. I also changed the orignal pap price in the script but it shows as 4500 still.

Sorry if i'm asking too much, but any tip or advice would be appreciated!

The post regarding double pap: https://zombiemodding.com/index.php?topic=12383.0 (Idk if i can post zm links)

Title: Re: Upgraded Weapon Problem
Post by: BluntStuffy on May 30, 2018, 04:39:36 pm
Quote
OMFG thank you so much. I've been trying to find a solution for this for ages. But i also have 2 questions regarding this.
1: In your post you said something about alt ammo, is alt ammo purchasable from the original weapon trigger? (ex: buys type 99, upgrades it, it gets gl attachment, buys type 99 upgraded ammo)

Tbh, i'm not really sure anymore. It's been a while since i messed with that ( as you can see from the date ). You would have to try and see, if it doesn't you could Always change the function in _zombiemode_weapons that give the ammo to the players.
I was trying some weird stuff with alt-weapons and ammo, so just ignore the talk about alt-ammo etc if you dont use it.

Quote
2: the hintstring don't seem to update from the script. The prices are 5000 for _upgraded_upgraded ammo but buying a gun, it just lists " 500(gun price) || 350 (ammo price) || 4500 (upgraded ammo price " instead of updating _upgraded price and adding _upgraded_upgraded's price. I also changed the orignal pap price in the script but it shows as 4500 still.
The hintstrings are 'fixed' so they wont update themself. You need to change them. So look for the sethintstring() lines. Most of them for weapons and PaP look like this:
Code Snippet
Plaintext
		weapon_cabs[i] SetHintString( &"ZOMBIE_CABINET_OPEN_1500" ); 

where it has the & infront of the " This indicates it's a localized string ( so it adjusts itself to the language you install the game with. You can either go to /raw/english/localizedstrings/ and look for the zombie.str. Then you can adjust them in there. You can also just hard-code them in your scripts by removing the & and just typing them out:
Code Snippet
Plaintext
		weapon_cabs[i] SetHintString( "Open weapon cabinet. Cost [1500]" ); 


Since there's no real benefit in localized strings for modding you are prob easier of just hardcoding them.

Spoiler: click to open...
btw, the hintstrings for weapons are in the add_zombie_weapon() function:
Code Snippet
Plaintext
	add_zombie_weapon( "kar98k_scoped_zombie", 					&"ZOMBIE_WEAPON_KAR98K_S_750", 				750,	"vox_ppsh",		5);
hope that helps,
Blunt


Title: Re: Upgraded Weapon Problem
Post by: Joeycx on May 30, 2018, 08:27:58 pm
Tbh, i'm not really sure anymore. It's been a while since i messed with that ( as you can see from the date ). You would have to try and see, if it doesn't you could Always change the function in _zombiemode_weapons that give the ammo to the players.
I was trying some weird stuff with alt-weapons and ammo, so just ignore the talk about alt-ammo etc if you dont use it.
The hintstrings are 'fixed' so they wont update themself. You need to change them. So look for the sethintstring() lines. Most of them for weapons and PaP look like this:
Code Snippet
Plaintext
		weapon_cabs[i] SetHintString( &"ZOMBIE_CABINET_OPEN_1500" ); 

where it has the & infront of the " This indicates it's a localized string ( so it adjusts itself to the language you install the game with. You can either go to /raw/english/localizedstrings/ and look for the zombie.str. Then you can adjust them in there. You can also just hard-code them in your scripts by removing the & and just typing them out:
Code Snippet
Plaintext
		weapon_cabs[i] SetHintString( "Open weapon cabinet. Cost [1500]" ); 


Since there's no real benefit in localized strings for modding you are prob easier of just hardcoding them.

Spoiler: click to open...
btw, the hintstrings for weapons are in the add_zombie_weapon() function:
Code Snippet
Plaintext
	add_zombie_weapon( "kar98k_scoped_zombie", 					&"ZOMBIE_WEAPON_KAR98K_S_750", 				750,	"vox_ppsh",		5);
hope that helps,
Blunt

Thank you so much for helping me. I found the string used for upgrading the weapon but setting it up is quite messy
Code Snippet
Plaintext
self SetHintString( &"ZOMBIE_WEAPONCOSTAMMO", cost, get_ammo_cost( self.zombie_weapon_upgrade ) ); 

but i'm unable to set up the values without setting the cost and get_ammo_cost, so if i do
Code Snippet
Plaintext
self SetHintString( "Upgraded Ammo [2500], Double Upgraded Ammo [5000]", cost, get_ammo_cost( self.zombie_weapon_upgrade ) ); 
it would appear like "Upgraded Ammo [2500], Double Upgraded Ammo [5000] 1000500" in game so i'm guessing the end numbers are the cost, and get_ammo_cost so how am i able to put them in so it will show the upgraded cost, double upgraded cost, weapon cost and ammo cost?  I tried the localized way and i was wondering why you said there was no benefit in doing it that way? Also is there a way to change the pap cost for _upgraded and _upgraded_upgraded? Sorry if i'm asking for to much lol.
Title: Re: Upgraded Weapon Problem
Post by: BluntStuffy on May 30, 2018, 09:18:13 pm
You can add a variable in a string with a + and if you want to continue the string you simply add a + after that and add a new string. So for example:

Code Snippet
Plaintext
	weapon_cost = 1000;
ammo_cost = 500;
pap_ammo = 4500;
pap2x_ammo = 8000;

trigger sethintstring( "Buy weapon, Cost: "+weapon_cost+" Ammo Cost "+ammo_cost+"Pap Ammo Cost: "+pap_ammo+" Double PaP ammo Cost: "+pap2x_ammo );


Localized strings are really only usefull if you want to release multiple langue-versions of your map. If you only make an english version using localized strings is only extra work for nothing.


You can change the pap-hintstring, sure. It will be more complicated to make it display the correct price depending on if you appraoch the machine with a paped or a non-paped weapon. But you can simply do something like.
"Press Use to upgrade weapon [5000]. Double upgrade [10000]"
It should be in zombiemode_perks somewhere, just search for sethintstring

Title: Re: Upgraded Weapon Problem
Post by: Joeycx on May 31, 2018, 12:18:30 pm
You can add a variable in a string with a + and if you want to continue the string you simply add a + after that and add a new string. So for example:

Code Snippet
Plaintext
	weapon_cost = 1000;
ammo_cost = 500;
pap_ammo = 4500;
pap2x_ammo = 8000;

trigger sethintstring( "Buy weapon, Cost: "+weapon_cost+" Ammo Cost "+ammo_cost+"Pap Ammo Cost: "+pap_ammo+" Double PaP ammo Cost: "+pap2x_ammo );


Localized strings are really only usefull if you want to release multiple langue-versions of your map. If you only make an english version using localized strings is only extra work for nothing.


You can change the pap-hintstring, sure. It will be more complicated to make it display the correct price depending on if you appraoch the machine with a paped or a non-paped weapon. But you can simply do something like.
"Press Use to upgrade weapon [5000]. Double upgrade [10000]"
It should be in zombiemode_perks somewhere, just search for sethintstring

I'm a very horrible at scripting so what you said was a bit confusing but i got it, i was able to use the sethingstring instead of the localized strings by doing this
Code Snippet
Plaintext
self SetHintString( "For Weapon [Cost: "+cost+"], Ammo ["+get_ammo_cost( self.zombie_weapon_upgrade )+"], Upgraded Ammo [Cost: 2500], Double Upgraded Ammo [Cost: 5000]" ); 
It worked in game but idk if could cause problems later on. But thank you so much for helping me :) One other question, i'm using harry's scripts for perks and pap so the strings and sethintstrings for the pap price aren't called there i think, because i looked for sethintstring and nothing regarding pap showed up so idk.
Title: Re: Upgraded Weapon Problem
Post by: BluntStuffy on May 31, 2018, 06:08:21 pm
Quote
It worked in game but idk if could cause problems later on. But thank you so much for helping me :)

That should work fine.


Quote
One other question, i'm using harry's scripts for perks and pap so the strings and sethintstrings for the pap price aren't called there i think, because i looked for sethintstring and nothing regarding pap showed up so idk.

Havent used those myself, so i couldn't tell you. Guess just open all files that come with it at the same time, and search through all of them at the same time for sethintstring(). Think i've seen him put a lot of variables at the top of his scripts, so it's eaasier for user to edit.
So it could be he included them as a 'setting' and stored the string in a variable at the top of a script somewhere..
Title: Re: Upgraded Weapon Problem
Post by: Joeycx on May 31, 2018, 08:22:20 pm
That should work fine.


Havent used those myself, so i couldn't tell you. Guess just open all files that come with it at the same time, and search through all of them at the same time for sethintstring(). Think i've seen him put a lot of variables at the top of his scripts, so it's eaasier for user to edit.
So it could be he included them as a 'setting' and stored the string in a variable at the top of a script somewhere..

I found the variable
Code Snippet
Plaintext
// ================================= PRECACHE MDOELS SHADERS AND WEAPON FILES AND SETTINGS =================================
harrybo21_perks_upgrade_add_machine( "normal_pack_a_punch", 5000, 30, "zombie_vending_packapunch", "zombie_vending_packapunch_on", "mx_packa_sting", "mx_packa_jingle", "packa_weap_upgrade", "packa_rollers_loop" );
harrybo21_perks_upgrade_add_machine( "alcatraz_pack_a_punch", 5000, 30, "bo2_p6_zm_al_vending_pap", "bo2_p6_zm_al_vending_pap_on", "mx_packa_sting", "mx_packa_jingle", "packa_weap_upgrade", "packa_rollers_loop" );
harrybo21_perks_upgrade_add_machine( "tranzit_pack_a_punch", 5000, 30, "bo2_p6_anim_zm_buildable_pap", "bo2_p6_anim_zm_buildable_pap_on", "mx_packa_sting", "mx_packa_jingle", "packa_weap_upgrade", "packa_rollers_loop" );
harrybo21_perks_upgrade_add_animated_machine( "origins_pack_a_punch", 5000, 30, "bo2_p6_zm_tm_packapunch", %fxanim_zom_tomb_packapunch_all_build_anim, %fxanim_zom_tomb_packapunch_all_break_anim, "tomb_perk_sting_pap", undefined,

But i wouldn't know how to script it to allow 5000 for the 1st upgrade and 10000 for 2nd upgrade since the script line is structured by
Code Snippet
Plaintext
( pap_name, pap_price, pap_gun_height, pap_model, pap_on_model, pap_sting, pap_jingle, pap_use, pap_idle_sound )

there's also this
Code Snippet
Plaintext
self.trig SetHintString( "Press & hold ^6&&1^7 to buy Pack A Punch [Cost: " + level.pack_a_punches[ self.trig.script_string ].pap_price + "]" );

but it works the same way as the script you showed me. so idk, very confusing lol.
Title: Re: Upgraded Weapon Problem
Post by: BluntStuffy on May 31, 2018, 09:21:33 pm
I found the variable
Code Snippet
Plaintext
// ================================= PRECACHE MDOELS SHADERS AND WEAPON FILES AND SETTINGS =================================
harrybo21_perks_upgrade_add_machine( "normal_pack_a_punch", 5000, 30, "zombie_vending_packapunch", "zombie_vending_packapunch_on", "mx_packa_sting", "mx_packa_jingle", "packa_weap_upgrade", "packa_rollers_loop" );
harrybo21_perks_upgrade_add_machine( "alcatraz_pack_a_punch", 5000, 30, "bo2_p6_zm_al_vending_pap", "bo2_p6_zm_al_vending_pap_on", "mx_packa_sting", "mx_packa_jingle", "packa_weap_upgrade", "packa_rollers_loop" );
harrybo21_perks_upgrade_add_machine( "tranzit_pack_a_punch", 5000, 30, "bo2_p6_anim_zm_buildable_pap", "bo2_p6_anim_zm_buildable_pap_on", "mx_packa_sting", "mx_packa_jingle", "packa_weap_upgrade", "packa_rollers_loop" );
harrybo21_perks_upgrade_add_animated_machine( "origins_pack_a_punch", 5000, 30, "bo2_p6_zm_tm_packapunch", %fxanim_zom_tomb_packapunch_all_build_anim, %fxanim_zom_tomb_packapunch_all_break_anim, "tomb_perk_sting_pap", undefined,

But i wouldn't know how to script it to allow 5000 for the 1st upgrade and 10000 for 2nd upgrade since the script line is structured by
Code Snippet
Plaintext
( pap_name, pap_price, pap_gun_height, pap_model, pap_on_model, pap_sting, pap_jingle, pap_use, pap_idle_sound )

All this stuff has nothing to do with the hintstring/price. it's for spawning the models etc



Quote
there's also this
Code Snippet
Plaintext
self.trig SetHintString( "Press & hold ^6&&1^7 to buy Pack A Punch [Cost: " + level.pack_a_punches[ self.trig.script_string ].pap_price + "]" );

but it works the same way as the script you showed me. so idk, very confusing lol.

That's the string you need to change, just type whatever you want here just like with the weapons. ( the .pap_price  variable sets the price for the normal pap, you can search where that variable is set.
Title: Re: Upgraded Weapon Problem
Post by: Joeycx on May 31, 2018, 09:38:10 pm
All this stuff has nothing to do with the hintstring/price. it's for spawning the models etc



That's the string you need to change, just type whatever you want here just like with the weapons. ( the .pap_price  variable sets the price for the normal pap, you can search where that variable is set.

But this is the pap_price
Code Snippet
Plaintext
harrybo21_perks_upgrade_add_machine( "normal_pack_a_punch", 5000, 30, "zombie_vending_packapunch", "zombie_vending_packapunch_on", "mx_packa_sting", "mx_packa_jingle", "packa_weap_upgrade", "packa_rollers_loop" );
harrybo21_perks_upgrade_add_machine( "alcatraz_pack_a_punch", 5000, 30, "bo2_p6_zm_al_vending_pap", "bo2_p6_zm_al_vending_pap_on", "mx_packa_sting", "mx_packa_jingle", "packa_weap_upgrade", "packa_rollers_loop" );
harrybo21_perks_upgrade_add_machine( "tranzit_pack_a_punch", 5000, 30, "bo2_p6_anim_zm_buildable_pap", "bo2_p6_anim_zm_buildable_pap_on", "mx_packa_sting", "mx_packa_jingle", "packa_weap_upgrade", "packa_rollers_loop" );
harrybo21_perks_upgrade_add_animated_machine( "origins_pack_a_punch", 5000, 30, "bo2_p6_zm_tm_packapunch", %fxanim_zom_tomb_packapunch_all_build_anim, %fxanim_zom_tomb_packapunch_all_break_anim, "tomb_perk_sting_pap", undefined, "tomb_perk_machine_pap", undefined );
The line with the 5000, when i change it, it changes the price, i just don't know how to make it 5000 for the first pap and 10000 for the second pap.

This is the structure harry put it as, so it matches the above and the pap_price already has a variable.
Code Snippet
Plaintext
harrybo21_perks_upgrade_add_machine( pap_name, pap_price, pap_gun_height, pap_model, pap_on_model, pap_sting, pap_jingle, pap_use, pap_idle_sound )

sorry if it sound like im contradicting you but i tried finding the pap_price and the only variable was the 5000 in the precache mdoels shaders and weapon files and settings.
Title: Re: Upgraded Weapon Problem
Post by: BluntStuffy on June 01, 2018, 01:52:10 pm
ah, ok. i missed the price-variable there. However, you still need to change that sethintstring and dont mess with the other lines.

Besides that you need to look for the PaP funtion ( stock-scripts it's in zombiemode_perks but for Harry i wouldn't know ), and the when the player pap's a weapon check it that weapon is allready upgraded or not. If it is the price is 10000, and if it's not the price is 5000.

If you want the hintstring to say either "Upgrade weapon. Cost [5000]." when a player holds a normal weapon, or "Double Upgrade weapon. Cost [10000]." when a player hold an upgraded weapon it's not impossible but it's going to require quite a lot of code for just a hintstring.
You could simply do "Upgrade weapon: Cost [5000]. Double Upgrade: Cost [10000]." and then asjust the cost by checking if the weapon is allready upgraded or not like i mentioned above.
Code Snippet
Plaintext
	cost = 5000;
weapon = player getcurrentweapon();


if( isSubStr( weapon, "_upgraded" ) )
{
cost = 10000;
}
Title: Re: Upgraded Weapon Problem
Post by: Joeycx on June 01, 2018, 05:30:34 pm
ah, ok. i missed the price-variable there. However, you still need to change that sethintstring and dont mess with the other lines.

Besides that you need to look for the PaP funtion ( stock-scripts it's in zombiemode_perks but for Harry i wouldn't know ), and the when the player pap's a weapon check it that weapon is allready upgraded or not. If it is the price is 10000, and if it's not the price is 5000.

If you want the hintstring to say either "Upgrade weapon. Cost [5000]." when a player holds a normal weapon, or "Double Upgrade weapon. Cost [10000]." when a player hold an upgraded weapon it's not impossible but it's going to require quite a lot of code for just a hintstring.
You could simply do "Upgrade weapon: Cost [5000]. Double Upgrade: Cost [10000]." and then asjust the cost by checking if the weapon is allready upgraded or not like i mentioned above.
Code Snippet
Plaintext
	cost = 5000;
weapon = player getcurrentweapon();


if( isSubStr( weapon, "_upgraded" ) )
{
cost = 10000;
}

It took a while but i finally got it working with the hintstring, so thank you so much bluntstuffy for answering all my questions, this is what i did, so please correct me if i did something wrong that would otherwise mess up things later.
Code Snippet
Plaintext
harrybo21_perks_upgraded_trigger_watcher( machine )
{
machine endon( "machine_removed" );
while( 1 )
{
player = undefined;
self waittill( "trigger", player );

if ( !machine.active || ( isDefined( player.is_drinking ) && player.is_drinking ) || player maps\_laststand::player_is_in_laststand() || player isThrowingGrenade() || player isSwitchingWeapons() )
{
wait .1;
continue;
}
cost = 5000;
        weapon = player getcurrentweapon();


       if( isSubStr( weapon, "_upgraded" ) )
       {
             cost = 10000;
       }
       if ( player.score < cost )
       {
             wait .1;
             continue;
       }
       current_weapon = player getCurrentWeapon();
if( !IsDefined( level.zombie_include_weapons[ current_weapon ] ) || !IsDefined( level.zombie_include_weapons[ current_weapon + "_upgraded" ] ) )
        continue;
                     
                player maps\_zombiemode_score::minus_to_player_score( cost );

self SetHintString( "" );
self stopLoopSound();
light_location = spawn( "script_model", machine.origin + ( 0, 0, 5 ) );
light_location.angles = ( machine.angles + ( 0, 90, 0 ) );
light_location setModel( "tag_origin" );

PlayFxOnTag( level._effect[ "fx_zombie_pap_fx" ], light_location, "tag_origin" );

playsoundatposition( "bottle_dispense3d", machine.origin );
rand = randomintrange( 1, 100 );
if( rand <= 8 )
player thread harrybo21_vending_play_quote( "upgrade_wait" );


player.inventory[ player harrybo21_get_weapon_index( current_weapon ) ] = "none";
player takeWeapon( current_weapon );
player thread do_knuckle_crack();
machine playSound( level.pack_a_punches[ self.script_string ].pap_sting );
weaponmodel = player harrybo21_perks_weapon_upgrade( current_weapon, machine.origin + ( 0, 0, level.pack_a_punches[ self.script_string ].pap_gun_height ), machine.angles + ( 0, 90, 0 ), machine );
               

self playLoopSound( "ticktock_loop" );
self thread harrybo21_perk_wait_for_timeout();
self thread harrybo21_perks_weapon_take_watcher( player, current_weapon, machine );
               

self SetHintString( "Press & hold ^6&&1^7 to take weapon" );

self waittill_either( "pap_timeout", "pap_taken" );
light_location delete();
player thread harrybo21_vending_play_quote( self.script_string );
self.current_weapon = "";
weaponmodel delete();
self stoploopsound();
self playLoopSound( level.pack_a_punches[ self.script_string ].pap_idle_sound );

self SetHintString( "Press & hold ^6&&1^7 to Pack A Punch [Cost: 5000] or Double Pack A Punch [Cost: 10000]" );

self notify( "machine_used" );
}
}

There isn't really a "best answer" so i suggest anyone having this problem as well to read through bluntstuffy's post above.

Title: Re: Upgraded Weapon Problem
Post by: death_reaper0 on June 01, 2018, 06:30:35 pm
looks good but didnt see anything that checks if player has enough points to buy, put this after the added part
Code Snippet
Plaintext
		if ( player.score < cost )
{
wait .1;
continue;
}

should look like

Code Snippet
Plaintext
        if( isSubStr( weapon, "_upgraded" ) )
{
cost = 10000;
}
if ( player.score < cost )
{
wait .1;
continue;
}
Title: Re: Upgraded Weapon Problem
Post by: Joeycx on June 01, 2018, 07:43:18 pm
looks good but didnt see anything that checks if player has enough points to buy, put this after the added part
Code Snippet
Plaintext
		if ( player.score < cost )
{
wait .1;
continue;
}

should look like

Code Snippet
Plaintext
        if( isSubStr( weapon, "_upgraded" ) )
{
cost = 10000;
}
if ( player.score < cost )
{
wait .1;
continue;
}

Okay i added it, thanks!