X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmonsters%2Fmonster%2Fshambler.qc;h=2e3f02a0623a86f5591c5b922e0f8ce13ee27b7d;hb=7b1c7d6a2f8f423b2642a4d2f5f07be9cd5890d0;hp=97e0d49ba5af3c13c5a5f2f1e22828685b0a1067;hpb=304b8158c9b753dd5674d055a1b91bd5472a66b8;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/monsters/monster/shambler.qc b/qcsrc/common/monsters/monster/shambler.qc index 97e0d49ba..2e3f02a06 100644 --- a/qcsrc/common/monsters/monster/shambler.qc +++ b/qcsrc/common/monsters/monster/shambler.qc @@ -1,30 +1,4 @@ -#ifndef SHAMBLER_H -#define SHAMBLER_H - -#ifndef MENUQC -MODEL(MON_SHAMBLER, M_Model("shambler.mdl")); -#endif - -CLASS(Shambler, Monster) - ATTRIB(Shambler, spawnflags, int, MONSTER_SIZE_BROKEN | MON_FLAG_SUPERMONSTER | MON_FLAG_MELEE | MON_FLAG_RANGED); - ATTRIB(Shambler, mins, vector, '-41 -41 -31'); - ATTRIB(Shambler, maxs, vector, '41 41 65'); -#ifndef MENUQC - ATTRIB(Shambler, m_model, Model, MDL_MON_SHAMBLER); -#endif - ATTRIB(Shambler, netname, string, "shambler"); - ATTRIB(Shambler, monster_name, string, _("Shambler")); -ENDCLASS(Shambler) - -REGISTER_MONSTER(SHAMBLER, NEW(Shambler)) { -#ifndef MENUQC - this.mr_precache(this); -#endif -} - -#endif - -#ifdef IMPLEMENTATION +#include "shambler.qh" #ifdef SVQC float autocvar_g_monster_shambler_health; @@ -68,7 +42,7 @@ void M_Shambler_Attack_Smash(entity this) tracebox(this.origin + v_forward * 50, this.mins * 0.5, this.maxs * 0.5, this.origin + v_forward * autocvar_g_monster_shambler_attack_smash_range, MOVE_NORMAL, this); if(trace_ent.takedamage) - Damage(trace_ent, this, this, (autocvar_g_monster_shambler_attack_smash_damage) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_SMASH.m_id, trace_ent.origin, normalize(trace_ent.origin - this.origin)); + Damage(trace_ent, this, this, (autocvar_g_monster_shambler_attack_smash_damage) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_SMASH.m_id, DMG_NOWEP, trace_ent.origin, normalize(trace_ent.origin - this.origin)); } void M_Shambler_Attack_Swing(entity this) @@ -76,83 +50,77 @@ void M_Shambler_Attack_Swing(entity this) Monster_Attack_Melee(this, this.enemy, (autocvar_g_monster_shambler_attack_claw_damage), ((random() >= 0.5) ? this.anim_melee2 : this.anim_melee3), this.attack_range, 0.8, DEATH_MONSTER_SHAMBLER_CLAW.m_id, true); } -#include +#include -void M_Shambler_Attack_Lightning_Explode(entity this) +void M_Shambler_Attack_Lightning_Explode(entity this, entity directhitentity) { - entity head; - sound(this, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM); Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1); this.event_damage = func_null; this.takedamage = DAMAGE_NO; - this.movetype = MOVETYPE_NONE; + set_movetype(this, MOVETYPE_NONE); this.velocity = '0 0 0'; - if(this.movetype == MOVETYPE_NONE) + if(this.move_movetype == MOVETYPE_NONE) this.velocity = this.oldvelocity; - RadiusDamage (this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_radius), world, world, (autocvar_g_monster_shambler_attack_lightning_force), this.projectiledeathtype, other); + RadiusDamage (this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_radius), + NULL, NULL, (autocvar_g_monster_shambler_attack_lightning_force), this.projectiledeathtype, DMG_NOWEP, directhitentity); - for(head = findradius(this.origin, (autocvar_g_monster_shambler_attack_lightning_radius_zap)); head; head = head.chain) if(head != this.realowner) if(head.takedamage) + FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_monster_shambler_attack_lightning_radius_zap, it != this.realowner && it.takedamage, { - te_csqc_lightningarc(this.origin, head.origin); - Damage(head, this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_ZAP.m_id, head.origin, '0 0 0'); - } + te_csqc_lightningarc(this.origin, it.origin); + Damage(it, this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_ZAP.m_id, DMG_NOWEP, it.origin, '0 0 0'); + }); - this.think = SUB_Remove_self; + setthink(this, SUB_Remove); this.nextthink = time + 0.2; } void M_Shambler_Attack_Lightning_Explode_use(entity this, entity actor, entity trigger) { - M_Shambler_Attack_Lightning_Explode(this); + M_Shambler_Attack_Lightning_Explode(this, trigger); } -void M_Shambler_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void M_Shambler_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { - if (this.health <= 0) + if (GetResource(this, RES_HEALTH) <= 0) return; if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions return; // g_projectiles_damage says to halt - this.health = this.health - damage; + TakeResource(this, RES_HEALTH, damage); - if (this.health <= 0) + if (GetResource(this, RES_HEALTH) <= 0) W_PrepareExplosionByDamage(this, attacker, adaptor_think2use); } -void M_Shambler_Attack_Lightning_Touch() -{SELFPARAM(); - PROJECTILE_TOUCH; +void M_Shambler_Attack_Lightning_Touch(entity this, entity toucher) +{ + PROJECTILE_TOUCH(this, toucher); - self.use(this, NULL, NULL); + this.use(this, NULL, toucher); } -void M_Shambler_Attack_Lightning_Think() -{SELFPARAM(); +void M_Shambler_Attack_Lightning_Think(entity this) +{ this.nextthink = time; if (time > this.cnt) { - other = world; - M_Shambler_Attack_Lightning_Explode(this); + M_Shambler_Attack_Lightning_Explode(this, NULL); return; } } void M_Shambler_Attack_Lightning(entity this) { - entity gren; - - monster_makevectors(this, this.enemy); - - gren = new(grenade); + entity gren = new(grenade); gren.owner = gren.realowner = this; gren.bot_dodge = true; gren.bot_dodgerating = (autocvar_g_monster_shambler_attack_lightning_damage); - gren.movetype = MOVETYPE_BOUNCE; + set_movetype(gren, MOVETYPE_BOUNCE); PROJECTILE_MAKETRIGGER(gren); gren.projectiledeathtype = DEATH_MONSTER_SHAMBLER_ZAP.m_id; setorigin(gren, CENTER_OR_VIEWOFS(this)); @@ -161,27 +129,30 @@ void M_Shambler_Attack_Lightning(entity this) gren.cnt = time + 5; gren.nextthink = time; - gren.think = M_Shambler_Attack_Lightning_Think; + setthink(gren, M_Shambler_Attack_Lightning_Think); gren.use = M_Shambler_Attack_Lightning_Explode_use; - gren.touch = M_Shambler_Attack_Lightning_Touch; + settouch(gren, M_Shambler_Attack_Lightning_Touch); gren.takedamage = DAMAGE_YES; - gren.health = 50; + SetResourceExplicit(gren, RES_HEALTH, 50); gren.damageforcescale = 0; gren.event_damage = M_Shambler_Attack_Lightning_Damage; gren.damagedbycontents = true; + IL_PUSH(g_damagedbycontents, gren); gren.missile_flags = MIF_SPLASH | MIF_ARC; W_SetupProjVelocity_Explicit(gren, v_forward, v_up, (autocvar_g_monster_shambler_attack_lightning_speed), (autocvar_g_monster_shambler_attack_lightning_speed_up), 0, 0, false); gren.angles = vectoangles (gren.velocity); gren.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, gren); + IL_PUSH(g_bot_dodge, gren); CSQCProjectile(gren, true, PROJECTILE_SHAMBLER_LIGHTNING, true); } .int state; -bool M_Shambler_Attack(int attack_type, entity actor, entity targ) +bool M_Shambler_Attack(int attack_type, entity actor, entity targ, .entity weaponentity) { switch(attack_type) { @@ -226,7 +197,7 @@ bool M_Shambler_Attack(int attack_type, entity actor, entity targ) return false; } -spawnfunc(monster_shambler) { Monster_Spawn(this, MON_SHAMBLER.monsterid); } +spawnfunc(monster_shambler) { Monster_Spawn(this, true, MON_SHAMBLER.monsterid); } #endif // SVQC #ifdef SVQC @@ -236,12 +207,12 @@ METHOD(Shambler, mr_think, bool(Shambler this, entity actor)) return true; } -METHOD(Shambler, mr_pain, bool(Shambler this, entity actor)) +METHOD(Shambler, mr_pain, float(Shambler this, entity actor, float damage_take, entity attacker, float deathtype)) { TC(Shambler, this); actor.pain_finished = time + 0.5; setanim(actor, actor.anim_pain1, true, true, false); - return true; + return damage_take; } METHOD(Shambler, mr_death, bool(Shambler this, entity actor)) @@ -251,7 +222,7 @@ METHOD(Shambler, mr_death, bool(Shambler this, entity actor)) return true; } #endif -#ifndef MENUQC +#ifdef GAMEQC METHOD(Shambler, mr_anim, bool(Shambler this, entity actor)) { TC(Shambler, this); @@ -269,19 +240,18 @@ METHOD(Shambler, mr_anim, bool(Shambler this, entity actor)) } #endif #ifdef SVQC -spawnfunc(item_health_mega); .float animstate_endtime; METHOD(Shambler, mr_setup, bool(Shambler this, entity actor)) { TC(Shambler, this); - if(!actor.health) actor.health = (autocvar_g_monster_shambler_health); + if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_shambler_health); if(!actor.attack_range) actor.attack_range = 150; if(!actor.speed) { actor.speed = (autocvar_g_monster_shambler_speed_walk); } if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_shambler_speed_run); } if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_shambler_speed_stop); } if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_shambler_damageforcescale); } - actor.monster_loot = spawnfunc_item_health_mega; + actor.monster_loot = ITEM_HealthMega; actor.weapon = WEP_ELECTRO.m_id; // matches attacks better than WEP_VORTEX setanim(actor, actor.anim_shoot, false, true, true); @@ -291,12 +261,4 @@ METHOD(Shambler, mr_setup, bool(Shambler this, entity actor)) return true; } - -METHOD(Shambler, mr_precache, bool(Shambler this)) -{ - TC(Shambler, this); - return true; -} -#endif - #endif