X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmonsters%2Fmonster%2Fmage.qc;h=88120a0ea7550acbb93cd46e9b94022165b18ba2;hb=62d736d8c3a51baf5fa3a4265e39a2b773704a91;hp=32383af5718e78fa530de6d2e44b620d0e7603ac;hpb=0071121b663dc3d841a2c28d27c1015899f0f402;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 32383af57..88120a0ea 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -12,7 +12,7 @@ METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weapon if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) { if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range; actor.enemy = Monster_FindTarget(actor); - W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_MageSpike_FIRE, CH_WEAPON_B, 0); + W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_MageSpike_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_MAGE.m_id); if (!IS_PLAYER(actor)) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin); M_Mage_Attack_Spike(actor, w_shotdir); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready); @@ -87,23 +87,31 @@ bool M_Mage_Defend_Heal_Check(entity this, entity targ) { if(targ == NULL) return false; - if(targ.health <= 0) + if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0) return false; if(DIFF_TEAM(targ, this) && targ != this.monster_follow) return false; if(STAT(FROZEN, targ)) return false; if(!IS_PLAYER(targ)) - return (IS_MONSTER(targ) && targ.health < targ.max_health); + return (IS_MONSTER(targ) && GetResourceAmount(targ, RESOURCE_HEALTH) < targ.max_health); if(targ.items & ITEM_Shield.m_itemid) return false; switch(this.skin) { - case 0: return (targ.health < autocvar_g_balance_health_regenstable); - case 1: return ((targ.ammo_cells && targ.ammo_cells < g_pickup_cells_max) || (targ.ammo_plasma && targ.ammo_plasma < g_pickup_plasma_max) || (targ.ammo_rockets && targ.ammo_rockets < g_pickup_rockets_max) || (targ.ammo_nails && targ.ammo_nails < g_pickup_nails_max) || (targ.ammo_shells && targ.ammo_shells < g_pickup_shells_max)); - case 2: return (targ.armorvalue < autocvar_g_balance_armor_regenstable); - case 3: return (targ.health > 0); + case 0: return (GetResourceAmount(targ, RESOURCE_HEALTH) < autocvar_g_balance_health_regenstable); + case 1: + { + return ((GetResourceAmount(targ, RESOURCE_CELLS) && GetResourceAmount(targ, RESOURCE_CELLS) < g_pickup_cells_max) + || (GetResourceAmount(targ, RESOURCE_PLASMA) && GetResourceAmount(targ, RESOURCE_PLASMA) < g_pickup_plasma_max) + || (GetResourceAmount(targ, RESOURCE_ROCKETS) && GetResourceAmount(targ, RESOURCE_ROCKETS) < g_pickup_rockets_max) + || (GetResourceAmount(targ, RESOURCE_BULLETS) && GetResourceAmount(targ, RESOURCE_BULLETS) < g_pickup_nails_max) + || (GetResourceAmount(targ, RESOURCE_SHELLS) && GetResourceAmount(targ, RESOURCE_SHELLS) < g_pickup_shells_max) + ); + } + case 2: return (GetResourceAmount(targ, RESOURCE_ARMOR) < autocvar_g_balance_armor_regenstable); + case 3: return (GetResourceAmount(targ, RESOURCE_HEALTH) > 0); } return false; @@ -118,7 +126,8 @@ void M_Mage_Attack_Spike_Explode(entity this, entity directhitentity) this.realowner.mage_spike = NULL; Send_Effect(EFFECT_EXPLOSION_SMALL, this.origin, '0 0 0', 1); - RadiusDamage (this, this.realowner, (autocvar_g_monster_mage_attack_spike_damage), (autocvar_g_monster_mage_attack_spike_damage) * 0.5, (autocvar_g_monster_mage_attack_spike_radius), NULL, NULL, 0, DEATH_MONSTER_MAGE.m_id, directhitentity); + RadiusDamage (this, this.realowner, (autocvar_g_monster_mage_attack_spike_damage), (autocvar_g_monster_mage_attack_spike_damage) * 0.5, (autocvar_g_monster_mage_attack_spike_radius), + NULL, NULL, 0, DEATH_MONSTER_MAGE.m_id, DMG_NOWEP, directhitentity); delete(this); } @@ -135,7 +144,7 @@ void M_Mage_Attack_Spike_Touch(entity this, entity toucher) // copied from W_Seeker_Think void M_Mage_Attack_Spike_Think(entity this) { - if (time > this.ltime || (this.enemy && this.enemy.health <= 0) || this.owner.health <= 0) { + if (time > this.ltime || (this.enemy && GetResourceAmount(this.enemy, RESOURCE_HEALTH) <= 0) || GetResourceAmount(this.owner, RESOURCE_HEALTH) <= 0) { this.projectiledeathtype |= HITTYPE_SPLASH; M_Mage_Attack_Spike_Explode(this, NULL); } @@ -225,26 +234,32 @@ void M_Mage_Defend_Heal(entity this) switch(this.skin) { case 0: - if(it.health < autocvar_g_balance_health_regenstable) it.health = bound(0, it.health + (autocvar_g_monster_mage_heal_allies), autocvar_g_balance_health_regenstable); + { + Heal(it, this, autocvar_g_monster_mage_heal_allies, autocvar_g_balance_health_regenstable); fx = EFFECT_HEALING; break; + } case 1: - if(it.ammo_cells) it.ammo_cells = bound(it.ammo_cells, it.ammo_cells + 1, g_pickup_cells_max); - if(it.ammo_plasma) it.ammo_plasma = bound(it.ammo_plasma, it.ammo_plasma + 1, g_pickup_plasma_max); - if(it.ammo_rockets) it.ammo_rockets = bound(it.ammo_rockets, it.ammo_rockets + 1, g_pickup_rockets_max); - if(it.ammo_shells) it.ammo_shells = bound(it.ammo_shells, it.ammo_shells + 2, g_pickup_shells_max); - if(it.ammo_nails) it.ammo_nails = bound(it.ammo_nails, it.ammo_nails + 5, g_pickup_nails_max); + { + if(GetResourceAmount(this, RESOURCE_CELLS)) GiveResourceWithLimit(it, RESOURCE_CELLS, 1, g_pickup_cells_max); + if(GetResourceAmount(this, RESOURCE_PLASMA)) GiveResourceWithLimit(it, RESOURCE_PLASMA, 1, g_pickup_plasma_max); + if(GetResourceAmount(this, RESOURCE_ROCKETS)) GiveResourceWithLimit(it, RESOURCE_ROCKETS, 1, g_pickup_rockets_max); + if(GetResourceAmount(this, RESOURCE_SHELLS)) GiveResourceWithLimit(it, RESOURCE_SHELLS, 2, g_pickup_shells_max); + if(GetResourceAmount(this, RESOURCE_BULLETS)) GiveResourceWithLimit(it, RESOURCE_BULLETS, 5, g_pickup_nails_max); + // TODO: fuel? fx = EFFECT_AMMO_REGEN; break; + } case 2: - if(it.armorvalue < autocvar_g_balance_armor_regenstable) + if(GetResourceAmount(it, RESOURCE_ARMOR) < autocvar_g_balance_armor_regenstable) { - it.armorvalue = bound(0, it.armorvalue + (autocvar_g_monster_mage_heal_allies), autocvar_g_balance_armor_regenstable); + GiveResourceWithLimit(it, RESOURCE_ARMOR, autocvar_g_monster_mage_heal_allies, autocvar_g_balance_armor_regenstable); fx = EFFECT_ARMOR_REPAIR; } break; case 3: - it.health = bound(0, it.health - ((it == this) ? (autocvar_g_monster_mage_heal_self) : (autocvar_g_monster_mage_heal_allies)), autocvar_g_balance_health_regenstable); + float hp = ((it == this) ? autocvar_g_monster_mage_heal_self : autocvar_g_monster_mage_heal_allies); + TakeResource(it, RESOURCE_HEALTH, hp); // TODO: use regular damage functions? needs a way to bypass friendly fire checks fx = EFFECT_RAGE; break; } @@ -254,9 +269,9 @@ void M_Mage_Defend_Heal(entity this) else { Send_Effect(EFFECT_HEALING, it.origin, '0 0 0', 1); - it.health = bound(0, it.health + (autocvar_g_monster_mage_heal_allies), it.max_health); + Heal(it, this, autocvar_g_monster_mage_heal_allies, RESOURCE_LIMIT_NONE); if(!(it.spawnflags & MONSTERFLAG_INVINCIBLE) && it.sprite) - WaypointSprite_UpdateHealth(it.sprite, it.health); + WaypointSprite_UpdateHealth(it.sprite, GetResourceAmount(it, RESOURCE_HEALTH)); } }); @@ -271,7 +286,8 @@ void M_Mage_Defend_Heal(entity this) void M_Mage_Attack_Push(entity this) { sound(this, CH_SHOTS, SND_TAGEXP1, 1, ATTEN_NORM); - RadiusDamage (this, this, (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_radius), NULL, NULL, (autocvar_g_monster_mage_attack_push_force), DEATH_MONSTER_MAGE.m_id, this.enemy); + RadiusDamage (this, this, (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_radius), + NULL, NULL, (autocvar_g_monster_mage_attack_push_force), DEATH_MONSTER_MAGE.m_id, DMG_NOWEP, this.enemy); Send_Effect(EFFECT_TE_EXPLOSION, this.origin, '0 0 0', 1); setanim(this, this.anim_shoot, true, true, true); @@ -309,14 +325,14 @@ void M_Mage_Attack_Teleport(entity this, entity targ) void M_Mage_Defend_Shield_Remove(entity this) { this.effects &= ~(EF_ADDITIVE | EF_BLUE); - this.armorvalue = autocvar_g_monsters_armor_blockpercent; + SetResourceAmountExplicit(this, RESOURCE_ARMOR, autocvar_g_monsters_armor_blockpercent); } void M_Mage_Defend_Shield(entity this) { this.effects |= (EF_ADDITIVE | EF_BLUE); this.mage_shield_delay = time + (autocvar_g_monster_mage_shield_delay); - this.armorvalue = (autocvar_g_monster_mage_shield_blockpercent); + SetResourceAmountExplicit(this, RESOURCE_ARMOR, autocvar_g_monster_mage_shield_blockpercent); this.mage_shield_time = time + (autocvar_g_monster_mage_shield_time); setanim(this, this.anim_shoot, true, true, true); this.attack_finished_single[0] = time + 1; @@ -403,16 +419,16 @@ METHOD(Mage, mr_think, bool(Mage thismon, entity actor)) }); } - if(actor.health < (autocvar_g_monster_mage_heal_minhealth) || need_help) + if(GetResourceAmount(actor, RESOURCE_HEALTH) < (autocvar_g_monster_mage_heal_minhealth) || need_help) if(time >= actor.attack_finished_single[0]) if(random() < 0.5) M_Mage_Defend_Heal(actor); - if(time >= actor.mage_shield_time && actor.armorvalue) + if(time >= actor.mage_shield_time && GetResourceAmount(actor, RESOURCE_ARMOR)) M_Mage_Defend_Shield_Remove(actor); if(actor.enemy) - if(actor.health < actor.max_health) + if(GetResourceAmount(actor, RESOURCE_HEALTH) < actor.max_health) if(time >= actor.mage_shield_delay) if(random() < 0.5) M_Mage_Defend_Shield(actor); @@ -453,7 +469,7 @@ METHOD(Mage, mr_anim, bool(Mage this, entity actor)) METHOD(Mage, mr_setup, bool(Mage this, entity actor)) { TC(Mage, this); - if(!actor.health) actor.health = (autocvar_g_monster_mage_health); + if(!GetResourceAmount(this, RESOURCE_HEALTH)) SetResourceAmountExplicit(actor, RESOURCE_HEALTH, autocvar_g_monster_mage_health); if(!actor.speed) { actor.speed = (autocvar_g_monster_mage_speed_walk); } if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_mage_speed_run); } if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_mage_speed_stop); }