From: Mario Date: Mon, 10 Sep 2018 14:57:29 +0000 (+1000) Subject: Make vehicles use the standard health resource instead of a custom field X-Git-Tag: xonotic-v0.8.5~1883 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2de06b575ae2ac2a3325cc2b358da47180e211dd;p=xonotic%2Fxonotic-data.pk3dir.git Make vehicles use the standard health resource instead of a custom field --- diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index d3994fd83..4962ddbe6 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -731,18 +731,17 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl return -5; // Cant touch this + if (GetResourceAmount(e_target, RESOURCE_HEALTH) <= 0) + return -6; + else if(STAT(FROZEN, e_target) > 0) + return -6; + + // vehicle if(IS_VEHICLE(e_target)) { - if (e_target.vehicle_health <= 0) - return -6; - if ((validate_flags & TFL_TARGETSELECT_VEHICLES) && !e_target.owner) return -7; } - else if (GetResourceAmount(e_target, RESOURCE_HEALTH) <= 0) - return -6; - else if(STAT(FROZEN, e_target) > 0) - return -6; // player if (IS_CLIENT(e_target)) diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 716dfe8d0..60df77090 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -587,7 +587,7 @@ void vehicles_regen(entity this, float timer, .float regen_field, float field_ma if(timer + rpause < time) { if(_healthscale) - regen = regen * (this.vehicle_health / this.max_health); + regen = regen * (GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health); this.(regen_field) = min(this.(regen_field) + regen * delta_time, field_max); @@ -596,6 +596,23 @@ void vehicles_regen(entity this, float timer, .float regen_field, float field_ma } } +void vehicles_regen_resource(entity this, float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale, int resource) +{ + float resource_amount = GetResourceAmount(this, resource); + + if(resource_amount < field_max) + if(timer + rpause < time) + { + if(_healthscale) + regen = regen * (resource_amount / this.max_health); + + SetResourceAmount(this, resource, min(resource_amount + regen * delta_time, field_max)); + + if(this.owner) + this.owner.(regen_field) = (GetResourceAmount(this, resource) / field_max) * 100; + } +} + void shieldhit_think(entity this) { this.alpha -= 0.1; @@ -613,7 +630,7 @@ void shieldhit_think(entity this) void vehicles_painframe(entity this) { - int myhealth = ((this.owner) ? this.owner.vehicle_health : ((this.vehicle_health / this.max_health) * 100)); + int myhealth = ((this.owner) ? this.owner.vehicle_health : ((GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health) * 100)); if(myhealth <= 50) if(this.pain_frame < time) @@ -684,7 +701,7 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag if(this.vehicle_shield < 0) { - this.vehicle_health -= fabs(this.vehicle_shield); + TakeResource(this, RESOURCE_HEALTH, fabs(this.vehicle_shield)); this.vehicle_shieldent.colormod = '2 0 0'; this.vehicle_shield = 0; this.vehicle_shieldent.alpha = 0.75; @@ -699,7 +716,7 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag } else { - this.vehicle_health -= damage; + TakeResource(this, RESOURCE_HEALTH, damage); if(sound_allowed(MSG_BROADCAST, attacker)) spamsound (this, CH_PAIN, SND_ONS_HIT2, VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER @@ -710,7 +727,7 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag else this.velocity += force; - if(this.vehicle_health <= 0) + if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0) { if(this.owner) if(this.vehicle_flags & VHF_DEATHEJECT) @@ -730,14 +747,12 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag bool vehicles_heal(entity targ, entity inflictor, float amount, float limit) { float true_limit = ((limit != RESOURCE_LIMIT_NONE) ? limit : targ.max_health); - //if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0 || GetResourceAmount(targ, RESOURCE_HEALTH) >= true_limit) - if(targ.vehicle_health <= 0 || targ.vehicle_health >= true_limit) + if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0 || GetResourceAmount(targ, RESOURCE_HEALTH) >= true_limit) return false; - targ.vehicle_health = min(targ.vehicle_health + amount, true_limit); - //GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit); - //if(targ.owner) - //targ.owner.vehicle_health = (targ.vehicle_health / targ.max_health) * 100; + GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit); + if(targ.owner) + targ.owner.vehicle_health = (GetResourceAmount(targ, RESOURCE_HEALTH) / targ.max_health) * 100; return true; } diff --git a/qcsrc/common/vehicles/sv_vehicles.qh b/qcsrc/common/vehicles/sv_vehicles.qh index 0cc9da56e..a1f23c1df 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qh +++ b/qcsrc/common/vehicles/sv_vehicles.qh @@ -45,7 +45,7 @@ float autocvar_g_vehicles_weapon_damagerate = 2; .entity gunner1; .entity gunner2; -.float vehicle_health = _STAT(VEHICLESTAT_HEALTH); /// If ent is player this is 0..100 indicating precentage of health left on vehicle. If ent is vehicle, this is the real health value. +.float vehicle_health = _STAT(VEHICLESTAT_HEALTH); /// If ent is player this is 0..100 indicating precentage of health left on vehicle. Vehicle's value is the health resource .float vehicle_energy = _STAT(VEHICLESTAT_ENERGY); /// If ent is player this is 0..100 indicating precentage of energy left on vehicle. If ent is vehicle, this is the real energy value. .float vehicle_shield = _STAT(VEHICLESTAT_SHIELD); /// If ent is player this is 0..100 indicating precentage of shield left on vehicle. If ent is vehicle, this is the real shield value. @@ -99,6 +99,9 @@ float vehicles_exit_running; #define VEHICLE_UPDATE_PLAYER(ply,vehi,fld,vhname) \ ply.vehicle_##fld = (vehi.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld) * 100 +#define VEHICLE_UPDATE_PLAYER_RESOURCE(ply,vehi,fld,vhname,res) \ + ply.vehicle_##fld = (GetResourceAmount(vehi, res) / autocvar_g_vehicle_##vhname##_##fld) * 100 + .float vehicle_enter_delay; // prevent players jumping to and from vehicles instantly void vehicles_exit(entity vehic, int eject); diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index c340d9470..f8620230c 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -160,7 +160,7 @@ bool bumblebee_gunner_frame(entity this, float dt) gun.attack_finished_single[0] = time + autocvar_g_vehicle_bumblebee_cannon_refire; } - VEHICLE_UPDATE_PLAYER(this, vehic, health, bumblebee); + VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, bumblebee, RESOURCE_HEALTH); if(vehic.vehicle_flags & VHF_HASSHIELD) VEHICLE_UPDATE_PLAYER(this, vehic, shield, bumblebee); @@ -389,7 +389,7 @@ void bumblebee_regen(entity this, float dt) vehicles_regen(this, this.dmg_time, vehicle_shield, autocvar_g_vehicle_bumblebee_shield, autocvar_g_vehicle_bumblebee_shield_regen_pause, autocvar_g_vehicle_bumblebee_shield_regen, dt, true); if(this.vehicle_flags & VHF_HEALTHREGEN) - vehicles_regen(this, this.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, dt, false); + vehicles_regen_resource(this, this.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, dt, false, RESOURCE_HEALTH); if(this.vehicle_flags & VHF_ENERGYREGEN) vehicles_regen(this, this.wait, vehicle_energy, autocvar_g_vehicle_bumblebee_energy, autocvar_g_vehicle_bumblebee_energy_regen_pause, autocvar_g_vehicle_bumblebee_energy_regen, dt, false); @@ -555,7 +555,7 @@ bool bumblebee_pilot_frame(entity this, float dt) if(IS_VEHICLE(trace_ent)) { - if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.max_health) + if(autocvar_g_vehicle_bumblebee_healgun_sps && GetResourceAmount(trace_ent, RESOURCE_HEALTH) <= trace_ent.max_health) trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * dt, trace_ent.tur_head.max_health); } else if(IS_CLIENT(trace_ent)) @@ -584,7 +584,7 @@ bool bumblebee_pilot_frame(entity this, float dt) } */ - VEHICLE_UPDATE_PLAYER(this, vehic, health, bumblebee); + VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, bumblebee, RESOURCE_HEALTH); VEHICLE_UPDATE_PLAYER(this, vehic, energy, bumblebee); this.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100; @@ -879,7 +879,7 @@ METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh, entity instance)) if(!autocvar_g_vehicle_bumblebee_swim) instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK; - instance.vehicle_health = autocvar_g_vehicle_bumblebee_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_bumblebee_health); instance.vehicle_shield = autocvar_g_vehicle_bumblebee_shield; instance.solid = SOLID_BBOX; set_movetype(instance, MOVETYPE_TOSS); @@ -906,8 +906,8 @@ METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh, entity instance)) instance.vehicle_exit = bumblebee_exit; instance.respawntime = autocvar_g_vehicle_bumblebee_respawntime; - instance.vehicle_health = autocvar_g_vehicle_bumblebee_health; - instance.max_health = instance.vehicle_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_bumblebee_health); + instance.max_health = GetResourceAmount(instance, RESOURCE_HEALTH); instance.vehicle_shield = autocvar_g_vehicle_bumblebee_shield; } diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 18e13bcbb..c7f7af8ac 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -359,12 +359,12 @@ bool racer_frame(entity this, float dt) vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_racer_shield, autocvar_g_vehicle_racer_shield_regen_pause, autocvar_g_vehicle_racer_shield_regen, dt, true); if(vehic.vehicle_flags & VHF_HEALTHREGEN) - vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_racer_health, autocvar_g_vehicle_racer_health_regen_pause, autocvar_g_vehicle_racer_health_regen, dt, false); + vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_racer_health, autocvar_g_vehicle_racer_health_regen_pause, autocvar_g_vehicle_racer_health_regen, dt, false, RESOURCE_HEALTH); if(vehic.vehicle_flags & VHF_ENERGYREGEN) vehicles_regen(vehic, vehic.wait, vehicle_energy, autocvar_g_vehicle_racer_energy, autocvar_g_vehicle_racer_energy_regen_pause, autocvar_g_vehicle_racer_energy_regen, dt, false); - VEHICLE_UPDATE_PLAYER(player, vehic, health, racer); + VEHICLE_UPDATE_PLAYER_RESOURCE(player, vehic, health, racer, RESOURCE_HEALTH); VEHICLE_UPDATE_PLAYER(player, vehic, energy, racer); if(vehic.vehicle_flags & VHF_HASSHIELD) @@ -514,7 +514,7 @@ METHOD(Racer, vr_enter, void(Racer thisveh, entity instance)) { #ifdef SVQC set_movetype(instance, MOVETYPE_BOUNCE); - instance.owner.vehicle_health = (instance.vehicle_health / autocvar_g_vehicle_racer_health) * 100; + instance.owner.vehicle_health = (GetResourceAmount(instance, RESOURCE_HEALTH) / autocvar_g_vehicle_racer_health) * 100; instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_racer_shield) * 100; if(instance.owner.flagcarried) @@ -544,7 +544,7 @@ METHOD(Racer, vr_spawn, void(Racer thisveh, entity instance)) setthink(instance, racer_think); instance.nextthink = time; - instance.vehicle_health = autocvar_g_vehicle_racer_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_racer_health); instance.vehicle_shield = autocvar_g_vehicle_racer_shield; set_movetype(instance, MOVETYPE_TOSS); @@ -557,7 +557,7 @@ METHOD(Racer, vr_spawn, void(Racer thisveh, entity instance)) instance.bouncefactor = autocvar_g_vehicle_racer_bouncefactor; instance.bouncestop = autocvar_g_vehicle_racer_bouncestop; instance.damageforcescale = 0.5; - instance.vehicle_health = autocvar_g_vehicle_racer_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_racer_health); instance.vehicle_shield = autocvar_g_vehicle_racer_shield; #endif } @@ -625,9 +625,9 @@ METHOD(Racer, vr_setup, void(Racer thisveh, entity instance)) instance.vehicle_flags |= VHF_HEALTHREGEN; instance.respawntime = autocvar_g_vehicle_racer_respawntime; - instance.vehicle_health = autocvar_g_vehicle_racer_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_racer_health); instance.vehicle_shield = autocvar_g_vehicle_racer_shield; - instance.max_health = instance.vehicle_health; + instance.max_health = GetResourceAmount(instance, RESOURCE_HEALTH); #endif #ifdef CSQC diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index f44dcc578..7591954f4 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -369,7 +369,7 @@ bool raptor_frame(entity this, float dt) vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, dt, true); if(vehic.vehicle_flags & VHF_HEALTHREGEN) - vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false); + vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false, RESOURCE_HEALTH); if(vehic.vehicle_flags & VHF_ENERGYREGEN) vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, dt, false); @@ -427,7 +427,7 @@ bool raptor_frame(entity this, float dt) } - VEHICLE_UPDATE_PLAYER(this, vehic, health, raptor); + VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RESOURCE_HEALTH); VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor); if(vehic.vehicle_flags & VHF_HASSHIELD) VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor); @@ -471,7 +471,7 @@ bool raptor_takeoff(entity this, float dt) vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, dt, true); if(vehic.vehicle_flags & VHF_HEALTHREGEN) - vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false); + vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false, RESOURCE_HEALTH); if(vehic.vehicle_flags & VHF_ENERGYREGEN) vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, dt, false); @@ -481,7 +481,7 @@ bool raptor_takeoff(entity this, float dt) this.vehicle_reload2 = bound(0, vehic.bomb1.alpha * 100, 100); this.vehicle_ammo2 = (this.vehicle_reload2 == 100) ? 100 : 0; - VEHICLE_UPDATE_PLAYER(this, vehic, health, raptor); + VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RESOURCE_HEALTH); VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor); if(vehic.vehicle_flags & VHF_HASSHIELD) VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor); @@ -594,7 +594,7 @@ METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance)) instance.owner.PlayerPhysplug = raptor_takeoff; set_movetype(instance, MOVETYPE_BOUNCEMISSILE); instance.solid = SOLID_SLIDEBOX; - instance.owner.vehicle_health = (instance.vehicle_health / autocvar_g_vehicle_raptor_health) * 100; + instance.owner.vehicle_health = (GetResourceAmount(instance, RESOURCE_HEALTH) / autocvar_g_vehicle_raptor_health) * 100; instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100; instance.velocity = '0 0 1'; // nudge upwards so takeoff sequence can work instance.tur_head.exteriormodeltoclient = instance.owner; @@ -701,7 +701,7 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance)) } instance.frame = 0; - instance.vehicle_health = autocvar_g_vehicle_raptor_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_raptor_health); instance.vehicle_shield = autocvar_g_vehicle_raptor_shield; set_movetype(instance, MOVETYPE_TOSS); instance.solid = SOLID_SLIDEBOX; @@ -720,7 +720,7 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance)) instance.bouncefactor = autocvar_g_vehicle_raptor_bouncefactor; instance.bouncestop = autocvar_g_vehicle_raptor_bouncestop; instance.damageforcescale = 0.25; - instance.vehicle_health = autocvar_g_vehicle_raptor_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_raptor_health); instance.vehicle_shield = autocvar_g_vehicle_raptor_shield; } METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance)) @@ -739,9 +739,9 @@ METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance)) instance.vehicle_exit = raptor_exit; instance.respawntime = autocvar_g_vehicle_raptor_respawntime; - instance.vehicle_health = autocvar_g_vehicle_raptor_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_raptor_health); instance.vehicle_shield = autocvar_g_vehicle_raptor_shield; - instance.max_health = instance.vehicle_health; + instance.max_health = GetResourceAmount(instance, RESOURCE_HEALTH); if(!autocvar_g_vehicle_raptor_swim) instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK; diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index 09d0eb2af..7352e1dbb 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -294,7 +294,7 @@ bool spiderbot_frame(entity this, float dt) vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, dt, true); if(vehic.vehicle_flags & VHF_HEALTHREGEN) - vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, dt, false); + vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, dt, false, RESOURCE_HEALTH); PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false; //this.vehicle_ammo2 = vehic.tur_head.frame; @@ -309,7 +309,7 @@ bool spiderbot_frame(entity this, float dt) this.oldorigin = this.origin; // negate fall damage this.velocity = vehic.velocity; - VEHICLE_UPDATE_PLAYER(this, vehic, health, spiderbot); + VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, spiderbot, RESOURCE_HEALTH); if(vehic.vehicle_flags & VHF_HASSHIELD) VEHICLE_UPDATE_PLAYER(this, vehic, shield, spiderbot); @@ -524,7 +524,7 @@ METHOD(Spiderbot, vr_enter, void(Spiderbot thisveh, entity instance)) STAT(VEHICLESTAT_W2MODE, instance) = SBRM_GUIDE; set_movetype(instance, MOVETYPE_WALK); CSQCVehicleSetup(instance.owner, 0); - instance.owner.vehicle_health = (instance.vehicle_health / autocvar_g_vehicle_spiderbot_health) * 100; + instance.owner.vehicle_health = (GetResourceAmount(instance, RESOURCE_HEALTH) / autocvar_g_vehicle_spiderbot_health) * 100; instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100; if(instance.owner.flagcarried) @@ -582,7 +582,7 @@ METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh, entity instance)) setorigin(instance, instance.pos1 + '0 0 128'); instance.angles = instance.pos2; instance.damageforcescale = 0.03; - instance.vehicle_health = autocvar_g_vehicle_spiderbot_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_spiderbot_health); instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield; instance.PlayerPhysplug = spiderbot_frame; @@ -599,9 +599,9 @@ METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance)) instance.vehicle_flags |= VHF_HEALTHREGEN; instance.respawntime = autocvar_g_vehicle_spiderbot_respawntime; - instance.vehicle_health = autocvar_g_vehicle_spiderbot_health; + SetResourceAmountExplicit(instance, RESOURCE_HEALTH, autocvar_g_vehicle_spiderbot_health); instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield; - instance.max_health = instance.vehicle_health; + instance.max_health = GetResourceAmount(instance, RESOURCE_HEALTH); instance.pushable = true; // spiderbot can use jumppads }