From 15f262ea89a460b48f0382d2117be34b2d75bc79 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Wed, 29 Mar 2023 01:40:04 -0700 Subject: [PATCH] Staffs: refill clip from stock on pick up --- scripts/zm/replaced/zm_tomb_craftables.gsc | 62 ++++++++++++++++++++++ scripts/zm/replaced/zm_tomb_main_quest.gsc | 19 ++++++- scripts/zm/zm_tomb/zm_tomb_reimagined.gsc | 5 +- 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/scripts/zm/replaced/zm_tomb_craftables.gsc b/scripts/zm/replaced/zm_tomb_craftables.gsc index 1efe5a9c..2e844f18 100644 --- a/scripts/zm/replaced/zm_tomb_craftables.gsc +++ b/scripts/zm/replaced/zm_tomb_craftables.gsc @@ -259,6 +259,68 @@ quadrotor_set_unavailable() level.quadrotor_status.pickup_trig.model ghost(); } +tomb_check_crafted_weapon_persistence( player ) +{ + if ( self.stub.equipname == "equip_dieseldrone_zm" ) + { + if ( level.quadrotor_status.picked_up ) + return true; + else if ( level.quadrotor_status.crafted ) + return false; + } + else if ( self.stub.weaponname == "staff_air_zm" || self.stub.weaponname == "staff_fire_zm" || self.stub.weaponname == "staff_lightning_zm" || self.stub.weaponname == "staff_water_zm" ) + { + if ( self is_unclaimed_staff_weapon( self.stub.weaponname ) ) + { + s_elemental_staff = get_staff_info_from_weapon_name( self.stub.weaponname, 0 ); + player maps\mp\zombies\_zm_weapons::weapon_give( s_elemental_staff.weapname, 0, 0 ); + + if ( isdefined( s_elemental_staff.prev_ammo_stock ) && isdefined( s_elemental_staff.prev_ammo_clip ) ) + { + clip_size = weaponclipsize( s_elemental_staff.weapname ); + + if ( s_elemental_staff.prev_ammo_clip < clip_size ) + { + clip_add = clip_size - s_elemental_staff.prev_ammo_clip; + + if (clip_add > s_elemental_staff.prev_ammo_stock) + { + clip_add = s_elemental_staff.prev_ammo_stock; + } + + s_elemental_staff.prev_ammo_clip += clip_add; + s_elemental_staff.prev_ammo_stock -= clip_add; + } + + player setweaponammostock( s_elemental_staff.weapname, s_elemental_staff.prev_ammo_stock ); + player setweaponammoclip( s_elemental_staff.weapname, s_elemental_staff.prev_ammo_clip ); + } + + if ( isdefined( level.zombie_craftablestubs[self.stub.equipname].str_taken ) ) + self.stub.hint_string = level.zombie_craftablestubs[self.stub.equipname].str_taken; + else + self.stub.hint_string = ""; + + self sethintstring( self.stub.hint_string ); + player track_craftables_pickedup( self.stub.craftablespawn ); + model = getent( "craftable_" + self.stub.weaponname, "targetname" ); + model ghost(); + self.stub thread track_crafted_staff_trigger(); + self.stub thread track_staff_weapon_respawn( player ); + set_player_staff( self.stub.weaponname, player ); + } + else + { + self.stub.hint_string = ""; + self sethintstring( self.stub.hint_string ); + } + + return true; + } + + return false; +} + tomb_custom_craftable_validation( player ) { if ( self.stub.equipname == "equip_dieseldrone_zm" ) diff --git a/scripts/zm/replaced/zm_tomb_main_quest.gsc b/scripts/zm/replaced/zm_tomb_main_quest.gsc index 2602d466..5195bebf 100644 --- a/scripts/zm/replaced/zm_tomb_main_quest.gsc +++ b/scripts/zm/replaced/zm_tomb_main_quest.gsc @@ -133,8 +133,8 @@ main_quest_init() foreach ( staff in level.a_elemental_staffs ) { - staff.prev_ammo_clip = weaponclipsize( staff_upgraded.weapname ); - staff.prev_ammo_stock = weaponmaxammo( staff_upgraded.weapname ); + staff.prev_ammo_clip = weaponclipsize( staff.weapname ); + staff.prev_ammo_stock = weaponmaxammo( staff.weapname ); staff.upgrade.downgrade = staff; staff.upgrade useweaponmodel( staff.weapname ); staff.upgrade showallparts(); @@ -299,12 +299,27 @@ watch_for_player_pickup_staff() staff_upgraded_reload() { self endon( "staff_equip" ); + + clip_size = weaponclipsize( self.weapname ); max_ammo = weaponmaxammo( self.weapname ); n_count = int( max_ammo / 20 ); b_reloaded = 0; while ( true ) { + if ( self.prev_ammo_clip < clip_size ) + { + clip_add = clip_size - self.prev_ammo_clip; + + if (clip_add > self.prev_ammo_stock) + { + clip_add = self.prev_ammo_stock; + } + + self.prev_ammo_clip += clip_add; + self.prev_ammo_stock -= clip_add; + } + if ( self.prev_ammo_stock >= max_ammo ) { self.prev_ammo_stock = max_ammo; diff --git a/scripts/zm/zm_tomb/zm_tomb_reimagined.gsc b/scripts/zm/zm_tomb/zm_tomb_reimagined.gsc index a8a6144d..72e907bd 100644 --- a/scripts/zm/zm_tomb/zm_tomb_reimagined.gsc +++ b/scripts/zm/zm_tomb/zm_tomb_reimagined.gsc @@ -57,8 +57,9 @@ init() level.zombie_init_done = ::zombie_init_done; level.special_weapon_magicbox_check = ::tomb_special_weapon_magicbox_check; level.custom_magic_box_timer_til_despawn = ::custom_magic_box_timer_til_despawn; - level.zombie_custom_equipment_setup = scripts\zm\replaced\zm_tomb_craftables::setup_quadrotor_purchase; - level.custom_craftable_validation = scripts\zm\replaced\zm_tomb_craftables::tomb_custom_craftable_validation; + level.zombie_craftable_persistent_weapon = scripts\zm\replaced\zm_tomb_craftables::tomb_check_crafted_weapon_persistence; + level.custom_craftable_validation = scripts\zm\replaced\zm_tomb_craftables::tomb_custom_craftable_validation; + level.zombie_custom_equipment_setup = scripts\zm\replaced\zm_tomb_craftables::setup_quadrotor_purchase; level thread increase_solo_door_prices(); level thread zombie_blood_dig_changes();