From a396e5a28d647699c1879d817e8bf71a4072e5bf Mon Sep 17 00:00:00 2001 From: func_vehicle <56104255+func-vehicle@users.noreply.github.com> Date: Sun, 28 Feb 2021 12:01:19 +1300 Subject: [PATCH] Fixed crash on map exit, AATs not being restored, camos possibly not being restored correctly --- .../WORKSHOPID_objectives.json} | 0 .../tables/zm/ZM_YOURMAPNAME_objectives.json | 15 ++++++ .../scripts/zm/_zm_lost_n_found.csc | 2 +- .../scripts/zm/_zm_lost_n_found.gsc | 53 ++++++++++++------- 4 files changed, 51 insertions(+), 19 deletions(-) rename ZM_YOURMAPNAME/gamedata/tables/{common/objectives.json => zm/WORKSHOPID_objectives.json} (100%) create mode 100644 ZM_YOURMAPNAME/gamedata/tables/zm/ZM_YOURMAPNAME_objectives.json diff --git a/ZM_YOURMAPNAME/gamedata/tables/common/objectives.json b/ZM_YOURMAPNAME/gamedata/tables/zm/WORKSHOPID_objectives.json similarity index 100% rename from ZM_YOURMAPNAME/gamedata/tables/common/objectives.json rename to ZM_YOURMAPNAME/gamedata/tables/zm/WORKSHOPID_objectives.json diff --git a/ZM_YOURMAPNAME/gamedata/tables/zm/ZM_YOURMAPNAME_objectives.json b/ZM_YOURMAPNAME/gamedata/tables/zm/ZM_YOURMAPNAME_objectives.json new file mode 100644 index 0000000..c69d176 --- /dev/null +++ b/ZM_YOURMAPNAME/gamedata/tables/zm/ZM_YOURMAPNAME_objectives.json @@ -0,0 +1,15 @@ +{ + "_meta": { + "Exported via": "HydraX by Scobalula" + }, + "data": [ + { + "id": "zm_lnf_waypoint", + "pulse_waypoint": "enable", + "show3dDirectionArrow": 1, + "waypoint_clamp": "enable", + "waypoint_image": "blacktransparent", + "waypoint_z_offset": 0 + } + ] +} \ No newline at end of file diff --git a/ZM_YOURMAPNAME/scripts/zm/_zm_lost_n_found.csc b/ZM_YOURMAPNAME/scripts/zm/_zm_lost_n_found.csc index abe2dd0..9d973a7 100644 --- a/ZM_YOURMAPNAME/scripts/zm/_zm_lost_n_found.csc +++ b/ZM_YOURMAPNAME/scripts/zm/_zm_lost_n_found.csc @@ -36,7 +36,7 @@ function animation_update( model, oldValue, newValue ) function lerp_percentage( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump ) { - model = GetUIModel(GetUIModelForController(localClientNum), "zmhud.lnfPercentage" ); + model = GetUIModel( GetUIModelForController(localClientNum), "zmhud.lnfPercentage" ); if ( IsDefined( model ) ) { if ( newVal == 1 ) diff --git a/ZM_YOURMAPNAME/scripts/zm/_zm_lost_n_found.gsc b/ZM_YOURMAPNAME/scripts/zm/_zm_lost_n_found.gsc index 148bf3d..a57629a 100644 --- a/ZM_YOURMAPNAME/scripts/zm/_zm_lost_n_found.gsc +++ b/ZM_YOURMAPNAME/scripts/zm/_zm_lost_n_found.gsc @@ -1,5 +1,6 @@ #using scripts\codescripts\struct; +#using scripts\shared\aat_shared; #using scripts\shared\array_shared; #using scripts\shared\clientfield_shared; #using scripts\shared\callbacks_shared; @@ -99,7 +100,7 @@ function private ephemeral_enhancement_validation_func_override() } // TODO: Validation is run twice when using BGB, once on press and once when the bubble animation finishes -// If second check fails, the activation is cancelled and this will never run after saving info! +// If second check fails, the activation is cancelled and this will never run after saving info! function private ephemeral_on_complete() { self waittill("activation_complete"); @@ -243,6 +244,9 @@ function private save_loadout_on_down() } loadout_ammo[weapon].stockAmmo = self GetWeaponAmmoStock(weapon); } + loadout_ammo[weapon].options = self GetWeaponOptions(weapon); + loadout_ammo[weapon].acvi = self GetWeaponAcvi(weapon); + loadout_ammo[weapon].aat = self.aat[weapon]; } // Tactical grenade tactical = self zm_utility::get_player_tactical_grenade(); @@ -272,6 +276,9 @@ function private save_loadout_on_down() loadout_ammo[weapon].clipAmmo = weapondata["clip"]; loadout_ammo[weapon].leftClipAmmo = weapondata["lh_clip"]; loadout_ammo[weapon].stockAmmo = weapondata["stock"]; + loadout_ammo[weapon].options = self GetWeaponOptions(weapon); + loadout_ammo[weapon].acvi = self GetWeaponAcvi(weapon); + loadout_ammo[weapon].aat = self.aat[weapon]; } } @@ -480,22 +487,21 @@ function return_weapons() weapons_given = 0; weapon_switched = false; - // Take their current weapons if not in saved loadout + // Take their current primaries foreach(weapon in self GetWeaponsListPrimaries()) { - if ( !array::contains(self.lnf_active_loadout, weapon) ) - { - self zm_weapons::weapon_take(weapon); - } + self zm_weapons::weapon_take(weapon); } // Give them their old loadout! - // TODO: test underbarrels - + // TODO: + // Underbarrels + // // TESTED: // Gobblegums (Disorderly Combat, Ephemeral Enhancement, etc) // Weapon restoration (+ Mule Kick w/ lower priority) // Ammo restoration (incl. Dual Wield) + // AAT restoration // Tactical grenade restoration // Lethal grenade restoration // Shield restoration @@ -608,21 +614,32 @@ function return_weapons() // Give the weapon if under the limit if (IsDefined(weapon_to_give) && weapons_given < weapon_limit) { - if (!self HasWeapon(weapon_to_give)) + // Give weapon + options = self.lnf_active_loadout_ammo[weapon_to_give].options; + acvi = self.lnf_active_loadout_ammo[weapon_to_give].acvi; + self GiveWeapon( weapon_to_give, options, acvi ); + if (!weapon_switched) { - self zm_weapons::weapon_give(weapon_to_give, 0, 0, 1, !weapon_switched); + self SwitchToWeapon(weapon_to_give); weapon_switched = true; } weapons_given++; - if (IsDefined(self.lnf_active_loadout_ammo[weapon_to_give])) + + // Set ammo + self SetWeaponAmmoClip(weapon_to_give, self.lnf_active_loadout_ammo[weapon_to_give].clipAmmo); + dual_wield_weapon = weapon_to_give.dualWieldWeapon; + if ( level.weaponNone != dual_wield_weapon ) { - self SetWeaponAmmoClip(weapon_to_give, self.lnf_active_loadout_ammo[weapon_to_give].clipAmmo); - dual_wield_weapon = weapon_to_give.dualWieldWeapon; - if ( level.weaponNone != dual_wield_weapon ) - { - self setWeaponAmmoClip(dual_wield_weapon, self.lnf_active_loadout_ammo[weapon_to_give].leftClipAmmo); - } - self SetWeaponAmmoStock(weapon_to_give, self.lnf_active_loadout_ammo[weapon_to_give].stockAmmo); + self setWeaponAmmoClip(dual_wield_weapon, self.lnf_active_loadout_ammo[weapon_to_give].leftClipAmmo); + } + self SetWeaponAmmoStock(weapon_to_give, self.lnf_active_loadout_ammo[weapon_to_give].stockAmmo); + + // Set AAT + aat = self.lnf_active_loadout_ammo[weapon_to_give].aat; + if(IsDefined(aat)) + { + self aat::remove(weapon_to_give); + self aat::acquire(weapon_to_give, aat); } } }