From: Mario Date: Sun, 3 Jan 2016 12:13:40 +0000 (+1000) Subject: Purge self from most of the monster code X-Git-Tag: xonotic-v0.8.2~1315 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=4f8174124060b4de8af7429fb9e7003f87e734c7 Purge self from most of the monster code --- diff --git a/qcsrc/common/animdecide.qc b/qcsrc/common/animdecide.qc index f8561b53ca..c4b428e493 100644 --- a/qcsrc/common/animdecide.qc +++ b/qcsrc/common/animdecide.qc @@ -7,49 +7,45 @@ #include "../server/defs.qh" #endif -bool monsters_animoverride(entity e) +bool monsters_animoverride(entity this) { Monster monster_id = NULL; - for(int i = MON_FIRST; i <= MON_LAST; ++i) - { - entity mon = get_monsterinfo(i); - - //if(substring(e.model, 0, strlen(mon.model) - 4) == substring(mon.model, 0, strlen(mon.model) - 4)) - if(e.model == mon.model) + FOREACH(Monsters, it != WEP_Null, LAMBDA( + if(it.model == this.model) { - monster_id = mon; + monster_id = it; break; } - } + )); if(!monster_id) { return false; } - monster_id.mr_anim(monster_id); + monster_id.mr_anim(monster_id, this); vector none = '0 0 0'; - e.anim_duckwalk = e.anim_walk; - e.anim_duckjump = animfixfps(e, '5 1 10', none); - e.anim_duckidle = e.anim_idle; - e.anim_jump = animfixfps(e, '8 1 10', none); - e.anim_taunt = animfixfps(e, '12 1 0.33', none); - e.anim_runbackwards = e.anim_run; - e.anim_strafeleft = e.anim_run; - e.anim_straferight = e.anim_run; - e.anim_forwardright = e.anim_run; - e.anim_forwardleft = e.anim_run; - e.anim_backright = e.anim_run; - e.anim_backleft = e.anim_run; - e.anim_duckwalkbackwards = e.anim_walk; - e.anim_duckwalkstrafeleft = e.anim_walk; - e.anim_duckwalkstraferight = e.anim_walk; - e.anim_duckwalkforwardright = e.anim_walk; - e.anim_duckwalkforwardleft = e.anim_walk; - e.anim_duckwalkbackright = e.anim_walk; - e.anim_duckwalkbackleft = e.anim_walk; + this.anim_duckwalk = this.anim_walk; + this.anim_duckjump = animfixfps(this, '5 1 10', none); + this.anim_duckidle = this.anim_idle; + this.anim_jump = animfixfps(this, '8 1 10', none); + this.anim_taunt = animfixfps(this, '12 1 0.33', none); + this.anim_runbackwards = this.anim_run; + this.anim_strafeleft = this.anim_run; + this.anim_straferight = this.anim_run; + this.anim_forwardright = this.anim_run; + this.anim_forwardleft = this.anim_run; + this.anim_backright = this.anim_run; + this.anim_backleft = this.anim_run; + this.anim_duckwalkbackwards = this.anim_walk; + this.anim_duckwalkstrafeleft = this.anim_walk; + this.anim_duckwalkstraferight = this.anim_walk; + this.anim_duckwalkforwardright = this.anim_walk; + this.anim_duckwalkforwardleft = this.anim_walk; + this.anim_duckwalkbackright = this.anim_walk; + this.anim_duckwalkbackleft = this.anim_walk; // these anims ought to stay until stopped explicitly by weaponsystem - e.anim_shoot_z = 0.001; - e.anim_melee_z = 0.001; + this.anim_shoot_z = 0.001; + this.anim_melee_z = 0.001; return true; } diff --git a/qcsrc/common/monsters/monster.qh b/qcsrc/common/monsters/monster.qh index 476dcfbe21..22e2072c08 100644 --- a/qcsrc/common/monsters/monster.qh +++ b/qcsrc/common/monsters/monster.qh @@ -25,7 +25,7 @@ const int MON_FLAG_RIDE = 4096; // monster can be ridden in special modes const int MONSTER_SIZE_QUAKE = 8192; // entity properties of monsterinfo: -.bool(int, entity targ) monster_attackfunc; +.bool(int, entity actor, entity targ) monster_attackfunc; // animations .vector anim_blockend; @@ -56,17 +56,17 @@ CLASS(Monster, Object) ATTRIB(Monster, maxs, vector, '0 0 0') /** (SERVER) setup monster data */ - METHOD(Monster, mr_setup, bool(Monster this)) { return false; } + METHOD(Monster, mr_setup, bool(Monster this, entity actor)) { return false; } /** (SERVER) logic to run every frame */ - METHOD(Monster, mr_think, bool(Monster this)) { return false; } + METHOD(Monster, mr_think, bool(Monster this, entity actor)) { return false; } /** (SERVER) called when monster dies */ - METHOD(Monster, mr_death, bool(Monster this)) { return false; } + METHOD(Monster, mr_death, bool(Monster this, entity actor)) { return false; } /** (BOTH) precaches models/sounds used by this monster */ METHOD(Monster, mr_precache, bool(Monster this)) { return false; } /** (SERVER) called when monster is damaged */ - METHOD(Monster, mr_pain, bool(Monster this)) { return false; } + METHOD(Monster, mr_pain, bool(Monster this, entity actor)) { return false; } /** (BOTH?) sets animations for monster */ - METHOD(Monster, mr_anim, bool(Monster this)) { return false; } + METHOD(Monster, mr_anim, bool(Monster this, entity actor)) { return false; } ENDCLASS(Monster) diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 2541de0a9b..c72e55015e 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -40,8 +40,8 @@ REGISTER_WEAPON(MAGE_SPIKE, NEW(MageSpike)); #ifdef SVQC SOUND(MageSpike_FIRE, W_Sound("electro_fire")); -void M_Mage_Attack_Spike(vector dir); -void M_Mage_Attack_Push(); +void M_Mage_Attack_Spike(entity this, vector dir); +void M_Mage_Attack_Push(entity this); METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weaponentity, int fire)) { if (fire & 1) if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) { @@ -49,24 +49,24 @@ METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, .entity weapon actor.enemy = Monster_FindTarget(actor); W_SetupShot_Dir(actor, v_forward, false, 0, SND(MageSpike_FIRE), CH_WEAPON_B, 0); if (!IS_PLAYER(actor)) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin); - M_Mage_Attack_Spike(w_shotdir); + M_Mage_Attack_Spike(actor, w_shotdir); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready); } if (fire & 2) if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, weaponentity, true, 0.5)) { - M_Mage_Attack_Push(); + M_Mage_Attack_Push(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready); } } -void M_Mage_Attack_Teleport(); +void M_Mage_Attack_Teleport(entity this, entity targ); CLASS(OffhandMageTeleport, OffhandWeapon) .bool OffhandMageTeleport_key_pressed; METHOD(OffhandMageTeleport, offhand_think, void(OffhandMageTeleport this, entity player, bool key_pressed)) { if (key_pressed && !player.OffhandMageTeleport_key_pressed) - WITH(entity, self, player, M_Mage_Attack_Teleport()); + M_Mage_Attack_Teleport(player, player.enemy); player.OffhandMageTeleport_key_pressed = key_pressed; } ENDCLASS(OffhandMageTeleport) @@ -110,58 +110,58 @@ const float mage_anim_death = 4; const float mage_anim_run = 5; */ -void() M_Mage_Defend_Heal; -void() M_Mage_Defend_Shield; +void M_Mage_Defend_Heal(entity this); +void M_Mage_Defend_Shield(entity this); .entity mage_spike; .float mage_shield_delay; .float mage_shield_time; -float M_Mage_Defend_Heal_Check(entity e) -{SELFPARAM(); - if(e == world) +bool M_Mage_Defend_Heal_Check(entity this, entity targ) +{ + if(targ == world) return false; - if(e.health <= 0) + if(targ.health <= 0) return false; - if(DIFF_TEAM(e, self) && e != self.monster_follow) + if(DIFF_TEAM(targ, this) && targ != this.monster_follow) return false; - if(STAT(FROZEN, e)) + if(STAT(FROZEN, targ)) return false; - if(!IS_PLAYER(e)) - return (IS_MONSTER(e) && e.health < e.max_health); - if(e.items & ITEM_Shield.m_itemid) + if(!IS_PLAYER(targ)) + return (IS_MONSTER(targ) && targ.health < targ.max_health); + if(targ.items & ITEM_Shield.m_itemid) return false; - switch(self.skin) + switch(this.skin) { - case 0: return (e.health < autocvar_g_balance_health_regenstable); - case 1: return ((e.ammo_cells && e.ammo_cells < g_pickup_cells_max) || (e.ammo_plasma && e.ammo_plasma < g_pickup_plasma_max) || (e.ammo_rockets && e.ammo_rockets < g_pickup_rockets_max) || (e.ammo_nails && e.ammo_nails < g_pickup_nails_max) || (e.ammo_shells && e.ammo_shells < g_pickup_shells_max)); - case 2: return (e.armorvalue < autocvar_g_balance_armor_regenstable); - case 3: return (e.health > 0); + 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); } return false; } -void M_Mage_Attack_Spike_Explode() -{SELFPARAM(); - self.event_damage = func_null; +void M_Mage_Attack_Spike_Explode(entity this) +{ + this.event_damage = func_null; - sound(self, CH_SHOTS, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM); + sound(this, CH_SHOTS, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM); - self.realowner.mage_spike = world; + this.realowner.mage_spike = world; - Send_Effect(EFFECT_EXPLOSION_SMALL, self.origin, '0 0 0', 1); - RadiusDamage (self, self.realowner, (autocvar_g_monster_mage_attack_spike_damage), (autocvar_g_monster_mage_attack_spike_damage) * 0.5, (autocvar_g_monster_mage_attack_spike_radius), world, world, 0, DEATH_MONSTER_MAGE.m_id, other); + 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), world, world, 0, DEATH_MONSTER_MAGE.m_id, other); - remove (self); + remove (this); } void M_Mage_Attack_Spike_Touch() { PROJECTILE_TOUCH; - M_Mage_Attack_Spike_Explode(); + M_Mage_Attack_Spike_Explode(self); } .float wait; @@ -171,7 +171,7 @@ void M_Mage_Attack_Spike_Think() {SELFPARAM(); if (time > self.ltime || (self.enemy && self.enemy.health <= 0) || self.owner.health <= 0) { self.projectiledeathtype |= HITTYPE_SPLASH; - M_Mage_Attack_Spike_Explode(); + M_Mage_Attack_Spike_Explode(self); } float spd = vlen(self.velocity); @@ -221,43 +221,42 @@ void M_Mage_Attack_Spike_Think() UpdateCSQCProjectile(self); } -void M_Mage_Attack_Spike(vector dir) +void M_Mage_Attack_Spike(entity this, vector dir) { - SELFPARAM(); - makevectors(self.angles); + makevectors(this.angles); entity missile = spawn(); - missile.owner = missile.realowner = self; + missile.owner = missile.realowner = this; missile.think = M_Mage_Attack_Spike_Think; missile.ltime = time + 7; missile.nextthink = time; missile.solid = SOLID_BBOX; missile.movetype = MOVETYPE_FLYMISSILE; missile.flags = FL_PROJECTILE; - setorigin(missile, self.origin + v_forward * 14 + '0 0 30' + v_right * -14); + setorigin(missile, this.origin + v_forward * 14 + '0 0 30' + v_right * -14); setsize(missile, '0 0 0', '0 0 0'); missile.velocity = dir * 400; missile.avelocity = '300 300 300'; - missile.enemy = self.enemy; + missile.enemy = this.enemy; missile.touch = M_Mage_Attack_Spike_Touch; - self.mage_spike = missile; + this.mage_spike = missile; CSQCProjectile(missile, true, PROJECTILE_MAGE_SPIKE, true); } -void M_Mage_Defend_Heal() -{SELFPARAM(); +void M_Mage_Defend_Heal(entity this) +{ entity head; float washealed = false; - for(head = findradius(self.origin, (autocvar_g_monster_mage_heal_range)); head; head = head.chain) if(M_Mage_Defend_Heal_Check(head)) + for(head = findradius(this.origin, (autocvar_g_monster_mage_heal_range)); head; head = head.chain) if(M_Mage_Defend_Heal_Check(this, head)) { washealed = true; string fx = ""; if(IS_PLAYER(head)) { - switch(self.skin) + switch(this.skin) { case 0: if(head.health < autocvar_g_balance_health_regenstable) head.health = bound(0, head.health + (autocvar_g_monster_mage_heal_allies), autocvar_g_balance_health_regenstable); @@ -279,7 +278,7 @@ void M_Mage_Defend_Heal() } break; case 3: - head.health = bound(0, head.health - ((head == self) ? (autocvar_g_monster_mage_heal_self) : (autocvar_g_monster_mage_heal_allies)), autocvar_g_balance_health_regenstable); + head.health = bound(0, head.health - ((head == this) ? (autocvar_g_monster_mage_heal_self) : (autocvar_g_monster_mage_heal_allies)), autocvar_g_balance_health_regenstable); fx = EFFECT_RAGE.eent_eff_name; break; } @@ -297,66 +296,69 @@ void M_Mage_Defend_Heal() if(washealed) { - setanim(self, self.anim_shoot, true, true, true); - self.attack_finished_single[0] = time + (autocvar_g_monster_mage_heal_delay); - self.anim_finished = time + 1.5; + setanim(this, this.anim_shoot, true, true, true); + this.attack_finished_single[0] = time + (autocvar_g_monster_mage_heal_delay); + this.anim_finished = time + 1.5; } } -void M_Mage_Attack_Push() -{SELFPARAM(); - sound(self, CH_SHOTS, SND_TAGEXP1, 1, ATTEN_NORM); - RadiusDamage (self, self, (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_radius), world, world, (autocvar_g_monster_mage_attack_push_force), DEATH_MONSTER_MAGE.m_id, self.enemy); - Send_Effect(EFFECT_TE_EXPLOSION, self.origin, '0 0 0', 1); +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), world, world, (autocvar_g_monster_mage_attack_push_force), DEATH_MONSTER_MAGE.m_id, this.enemy); + Send_Effect(EFFECT_TE_EXPLOSION, this.origin, '0 0 0', 1); - setanim(self, self.anim_shoot, true, true, true); - self.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_push_delay); + setanim(this, this.anim_shoot, true, true, true); + this.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_push_delay); } -void M_Mage_Attack_Teleport() -{SELFPARAM(); - entity targ = self.enemy; - if (!targ) return; - if (vlen(targ.origin - self.origin) > 1500) return; +void M_Mage_Attack_Teleport(entity this, entity targ) +{ + if(!targ) return; + if(vdist(targ.origin - this.origin, >, 1500)) return; makevectors(targ.angles); - tracebox(targ.origin + ((v_forward * -1) * 200), self.mins, self.maxs, self.origin, MOVE_NOMONSTERS, self); + tracebox(targ.origin + ((v_forward * -1) * 200), this.mins, this.maxs, this.origin, MOVE_NOMONSTERS, this); if(trace_fraction < 1) return; - Send_Effect(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1); - setorigin(self, targ.origin + ((v_forward * -1) * 200)); + vector newpos = targ.origin + ((v_forward * -1) * 200); + + Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); + Send_Effect(EFFECT_SPAWN_NEUTRAL, newpos, '0 0 0', 1); + + setorigin(this, newpos); - vector a = vectoangles(targ.origin - self.origin); + vector a = vectoangles(targ.origin - this.origin); a.x = -a.x; - self.angles_x = a.x; - self.angles_y = a.y; - self.fixangle = true; - self.velocity *= 0.5; + this.angles_x = a.x; + this.angles_y = a.y; + this.fixangle = true; + this.velocity *= 0.5; - self.attack_finished_single[0] = time + 0.2; + this.attack_finished_single[0] = time + 0.2; } -void M_Mage_Defend_Shield_Remove() -{SELFPARAM(); - self.effects &= ~(EF_ADDITIVE | EF_BLUE); - self.armorvalue = autocvar_g_monsters_armor_blockpercent; +void M_Mage_Defend_Shield_Remove(entity this) +{ + this.effects &= ~(EF_ADDITIVE | EF_BLUE); + this.armorvalue = autocvar_g_monsters_armor_blockpercent; } -void M_Mage_Defend_Shield() -{SELFPARAM(); - self.effects |= (EF_ADDITIVE | EF_BLUE); - self.mage_shield_delay = time + (autocvar_g_monster_mage_shield_delay); - self.armorvalue = (autocvar_g_monster_mage_shield_blockpercent); - self.mage_shield_time = time + (autocvar_g_monster_mage_shield_time); - setanim(self, self.anim_shoot, true, true, true); - self.attack_finished_single[0] = time + 1; - self.anim_finished = time + 1; +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); + 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; + this.anim_finished = time + 1; } -float M_Mage_Attack(float attack_type, entity targ) -{SELFPARAM(); +bool M_Mage_Attack(int attack_type, entity actor, entity targ) +{ .entity weaponentity = weaponentities[0]; switch(attack_type) { @@ -366,7 +368,7 @@ float M_Mage_Attack(float attack_type, entity targ) { Weapon wep = WEP_MAGE_SPIKE; - wep.wr_think(wep, self, weaponentity, 2); + wep.wr_think(wep, actor, weaponentity, 2); return true; } @@ -374,26 +376,26 @@ float M_Mage_Attack(float attack_type, entity targ) } case MONSTER_ATTACK_RANGED: { - if(!self.mage_spike) + if(!actor.mage_spike) { if(random() <= 0.4) { OffhandWeapon off = OFFHAND_MAGE_TELEPORT; - off.offhand_think(off, self, true); + off.offhand_think(off, actor, true); return true; } else { - setanim(self, self.anim_shoot, true, true, true); - self.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_spike_delay); - self.anim_finished = time + 1; + setanim(actor, actor.anim_shoot, true, true, true); + actor.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_spike_delay); + actor.anim_finished = time + 1; Weapon wep = WEP_MAGE_SPIKE; - wep.wr_think(wep, self, weaponentity, 1); + wep.wr_think(wep, actor, weaponentity, 1); return true; } } - if(self.mage_spike) + if(actor.mage_spike) return true; else return false; @@ -403,86 +405,82 @@ float M_Mage_Attack(float attack_type, entity targ) return false; } -spawnfunc(monster_mage) { Monster_Spawn(MON_MAGE.monsterid); } +spawnfunc(monster_mage) { Monster_Spawn(this, MON_MAGE.monsterid); } #endif // SVQC #ifdef SVQC - METHOD(Mage, mr_think, bool(Monster thismon)) + METHOD(Mage, mr_think, bool(Mage thismon, entity actor)) { - SELFPARAM(); - entity head; bool need_help = false; - for(head = world; (head = findfloat(head, iscreature, true)); ) - if(head != self) - if(vlen(head.origin - self.origin) <= (autocvar_g_monster_mage_heal_range)) - if(M_Mage_Defend_Heal_Check(head)) + FOREACH_ENTITY_FLOAT(iscreature, true, { - need_help = true; - break; - } + if(it != actor) + if(vdist(it.origin - actor.origin, <=, autocvar_g_monster_mage_heal_range)) + if(M_Mage_Defend_Heal_Check(actor, it)) + { + need_help = true; + break; + } + }); - if(self.health < (autocvar_g_monster_mage_heal_minhealth) || need_help) - if(time >= self.attack_finished_single[0]) + if(actor.health < (autocvar_g_monster_mage_heal_minhealth) || need_help) + if(time >= actor.attack_finished_single[0]) if(random() < 0.5) - M_Mage_Defend_Heal(); + M_Mage_Defend_Heal(actor); - if(time >= self.mage_shield_time && self.armorvalue) - M_Mage_Defend_Shield_Remove(); + if(time >= actor.mage_shield_time && actor.armorvalue) + M_Mage_Defend_Shield_Remove(actor); - if(self.enemy) - if(self.health < self.max_health) - if(time >= self.mage_shield_delay) + if(actor.enemy) + if(actor.health < actor.max_health) + if(time >= actor.mage_shield_delay) if(random() < 0.5) - M_Mage_Defend_Shield(); + M_Mage_Defend_Shield(actor); return true; } - METHOD(Mage, mr_pain, bool(Monster thismon)) + METHOD(Mage, mr_pain, bool(Mage thismon, entity actor)) { return true; } - METHOD(Mage, mr_death, bool(Monster thismon)) + METHOD(Mage, mr_death, bool(Mage thismon, entity actor)) { - SELFPARAM(); - setanim(self, self.anim_die1, false, true, true); + setanim(actor, actor.anim_die1, false, true, true); return true; } #endif #ifndef MENUQC - METHOD(Mage, mr_anim, bool(Monster thismon)) + METHOD(Mage, mr_anim, bool(Mage thismon, entity actor)) { - SELFPARAM(); vector none = '0 0 0'; - self.anim_die1 = animfixfps(self, '4 1 0.5', none); // 2 seconds - self.anim_walk = animfixfps(self, '1 1 1', none); - self.anim_idle = animfixfps(self, '0 1 1', none); - self.anim_pain1 = animfixfps(self, '3 1 2', none); // 0.5 seconds - self.anim_shoot = animfixfps(self, '2 1 5', none); // analyze models and set framerate - self.anim_run = animfixfps(self, '5 1 1', none); - + actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds + actor.anim_walk = animfixfps(actor, '1 1 1', none); + actor.anim_idle = animfixfps(actor, '0 1 1', none); + actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds + actor.anim_shoot = animfixfps(actor, '2 1 5', none); // analyze models and set framerate + actor.anim_run = animfixfps(actor, '5 1 1', none); return true; } #endif #ifdef SVQC .float speed; spawnfunc(item_health_large); - METHOD(Mage, mr_setup, bool(Monster thismon)) + METHOD(Mage, mr_setup, bool(Mage thismon, entity actor)) { - SELFPARAM(); - if(!self.health) self.health = (autocvar_g_monster_mage_health); - if(!self.speed) { self.speed = (autocvar_g_monster_mage_speed_walk); } - if(!self.speed2) { self.speed2 = (autocvar_g_monster_mage_speed_run); } - if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_mage_speed_stop); } - if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_mage_damageforcescale); } + if(!actor.health) actor.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); } + if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_mage_damageforcescale); } - self.monster_loot = spawnfunc_item_health_large; - self.monster_attackfunc = M_Mage_Attack; + actor.monster_loot = spawnfunc_item_health_large; + actor.monster_attackfunc = M_Mage_Attack; return true; } - METHOD(Mage, mr_precache, bool(Monster thismon)) + METHOD(Mage, mr_precache, bool(Mage thismon)) { return true; } diff --git a/qcsrc/common/monsters/monster/shambler.qc b/qcsrc/common/monsters/monster/shambler.qc index c642cb5fa4..e77902be22 100644 --- a/qcsrc/common/monsters/monster/shambler.qc +++ b/qcsrc/common/monsters/monster/shambler.qc @@ -57,29 +57,23 @@ const float shambler_anim_death = 8; .float shambler_lastattack; // delay attacks separately -void M_Shambler_Attack_Smash() -{SELFPARAM(); - makevectors(self.angles); - Send_Effect(EFFECT_EXPLOSION_MEDIUM, (self.origin + (v_forward * 150)) - ('0 0 1' * self.maxs.z), '0 0 0', 1); - sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); +void M_Shambler_Attack_Smash(entity this) +{ + makevectors(this.angles); + Send_Effect(EFFECT_EXPLOSION_MEDIUM, (this.origin + (v_forward * 150)) - ('0 0 1' * this.maxs.z), '0 0 0', 1); + sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); // RadiusDamage does NOT support custom starting location, which means we must use this hack... - tracebox(self.origin + v_forward * 50, self.mins * 0.5, self.maxs * 0.5, self.origin + v_forward * autocvar_g_monster_shambler_attack_smash_range, MOVE_NORMAL, self); + 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, self, self, (autocvar_g_monster_shambler_attack_smash_damage) * MONSTER_SKILLMOD(self), DEATH_MONSTER_SHAMBLER_SMASH.m_id, trace_ent.origin, normalize(trace_ent.origin - self.origin)); + 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)); } -void M_Shambler_Attack_Swing() -{SELFPARAM(); - float r = (random() < 0.5); - if(r && Monster_Attack_Melee(self.enemy, (autocvar_g_monster_shambler_attack_claw_damage), ((r) ? self.anim_melee2 : self.anim_melee3), self.attack_range, 0.8, DEATH_MONSTER_SHAMBLER_CLAW.m_id, true)) - { - Monster_Delay(1, 0, 0.5, M_Shambler_Attack_Swing); - self.attack_finished_single[0] += 0.5; - self.anim_finished = self.attack_finished_single[0]; - } +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 @@ -89,7 +83,7 @@ void M_Shambler_Attack_Lightning_Explode() entity head; sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM); - Send_Effect(EFFECT_ELECTRO_IMPACT, '0 0 0', '0 0 0', 1); + Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1); self.event_damage = func_null; self.takedamage = DAMAGE_NO; @@ -143,20 +137,20 @@ void M_Shambler_Attack_Lightning_Think() } } -void M_Shambler_Attack_Lightning() -{SELFPARAM(); +void M_Shambler_Attack_Lightning(entity this) +{ entity gren; - monster_makevectors(self.enemy); + monster_makevectors(this, this.enemy); gren = new(grenade); - gren.owner = gren.realowner = self; + gren.owner = gren.realowner = this; gren.bot_dodge = true; gren.bot_dodgerating = (autocvar_g_monster_shambler_attack_lightning_damage); gren.movetype = MOVETYPE_BOUNCE; PROJECTILE_MAKETRIGGER(gren); gren.projectiledeathtype = DEATH_MONSTER_SHAMBLER_ZAP.m_id; - setorigin(gren, CENTER_OR_VIEWOFS(self)); + setorigin(gren, CENTER_OR_VIEWOFS(this)); setsize(gren, '-8 -8 -8', '8 8 8'); gren.scale = 2.5; @@ -182,39 +176,41 @@ void M_Shambler_Attack_Lightning() .int state; -float M_Shambler_Attack(float attack_type, entity targ) -{SELFPARAM(); +bool M_Shambler_Attack(int attack_type, entity actor, entity targ) +{ switch(attack_type) { case MONSTER_ATTACK_MELEE: { - M_Shambler_Attack_Swing(); + int swing_cnt = bound(1, floor(random() * 4), 3); + Monster_Delay(actor, swing_cnt, 0.5, M_Shambler_Attack_Swing); + actor.anim_finished = actor.attack_finished_single[0] = time + (0.5 * swing_cnt); // set this for the delay return true; } case MONSTER_ATTACK_RANGED: { - float randomness = random(), enemy_len = vlen(self.enemy.origin - self.origin); + float randomness = random(), enemy_len = vlen(actor.enemy.origin - actor.origin); - if(time >= self.shambler_lastattack) // shambler doesn't attack much - if(IS_ONGROUND(self)) + if(time >= actor.shambler_lastattack) // shambler doesn't attack much + if(IS_ONGROUND(actor)) if(randomness <= 0.5 && enemy_len <= autocvar_g_monster_shambler_attack_smash_range) { - setanim(self, self.anim_melee2, true, true, false); - Monster_Delay(1, 0, 0.7, M_Shambler_Attack_Smash); - self.attack_finished_single[0] = time + 1.1; - self.anim_finished = time + 1.1; - self.state = MONSTER_ATTACK_MELEE; // kinda a melee attack - self.shambler_lastattack = time + 3 + random() * 1.5; + setanim(actor, actor.anim_melee2, true, true, false); + Monster_Delay(actor, 1, 0.7, M_Shambler_Attack_Smash); + actor.attack_finished_single[0] = time + 1.1; + actor.anim_finished = time + 1.1; + actor.state = MONSTER_ATTACK_MELEE; // kinda a melee attack + actor.shambler_lastattack = time + 3 + random() * 1.5; return true; } else if(randomness <= 0.1 && enemy_len >= autocvar_g_monster_shambler_attack_smash_range * 1.5) // small chance, don't want this spammed { - setanim(self, self.anim_shoot, true, true, false); - self.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general - self.attack_finished_single[0] = time + 1.1; - self.anim_finished = 1.1; - self.shambler_lastattack = time + 3 + random() * 1.5; - Monster_Delay(1, 0, 0.6, M_Shambler_Attack_Lightning); + setanim(actor, actor.anim_shoot, true, true, false); + actor.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general + actor.attack_finished_single[0] = time + 1.1; + actor.anim_finished = 1.1; + actor.shambler_lastattack = time + 3 + random() * 1.5; + Monster_Delay(actor, 1, 0.6, M_Shambler_Attack_Lightning); return true; } @@ -225,66 +221,61 @@ float M_Shambler_Attack(float attack_type, entity targ) return false; } -spawnfunc(monster_shambler) { Monster_Spawn(MON_SHAMBLER.monsterid); } +spawnfunc(monster_shambler) { Monster_Spawn(this, MON_SHAMBLER.monsterid); } #endif // SVQC #ifdef SVQC - METHOD(Shambler, mr_think, bool(Shambler thismon)) + METHOD(Shambler, mr_think, bool(Shambler thismon, entity actor)) { return true; } - METHOD(Shambler, mr_pain, bool(Shambler thismon)) + METHOD(Shambler, mr_pain, bool(Shambler thismon, entity actor)) { - SELFPARAM(); - self.pain_finished = time + 0.5; - setanim(self, self.anim_pain1, true, true, false); + actor.pain_finished = time + 0.5; + setanim(actor, actor.anim_pain1, true, true, false); return true; } - METHOD(Shambler, mr_death, bool(Shambler thismon)) + METHOD(Shambler, mr_death, bool(Shambler thismon, entity actor)) { - SELFPARAM(); - setanim(self, self.anim_die1, false, true, true); + setanim(actor, actor.anim_die1, false, true, true); return true; } #endif #ifndef MENUQC - METHOD(Shambler, mr_anim, bool(Shambler thismon)) + METHOD(Shambler, mr_anim, bool(Shambler thismon, entity actor)) { - SELFPARAM(); vector none = '0 0 0'; - self.anim_die1 = animfixfps(self, '8 1 0.5', none); // 2 seconds - self.anim_walk = animfixfps(self, '1 1 1', none); - self.anim_idle = animfixfps(self, '0 1 1', none); - self.anim_pain1 = animfixfps(self, '7 1 2', none); // 0.5 seconds - self.anim_melee1 = animfixfps(self, '3 1 5', none); // analyze models and set framerate - self.anim_melee2 = animfixfps(self, '4 1 5', none); // analyze models and set framerate - self.anim_melee3 = animfixfps(self, '5 1 5', none); // analyze models and set framerate - self.anim_shoot = animfixfps(self, '6 1 5', none); // analyze models and set framerate - self.anim_run = animfixfps(self, '2 1 1', none); - + actor.anim_die1 = animfixfps(actor, '8 1 0.5', none); // 2 seconds + actor.anim_walk = animfixfps(actor, '1 1 1', none); + actor.anim_idle = animfixfps(actor, '0 1 1', none); + actor.anim_pain1 = animfixfps(actor, '7 1 2', none); // 0.5 seconds + actor.anim_melee1 = animfixfps(actor, '3 1 5', none); // analyze models and set framerate + actor.anim_melee2 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate + actor.anim_melee3 = animfixfps(actor, '5 1 5', none); // analyze models and set framerate + actor.anim_shoot = animfixfps(actor, '6 1 5', none); // analyze models and set framerate + actor.anim_run = animfixfps(actor, '2 1 1', none); return true; } #endif #ifdef SVQC spawnfunc(item_health_mega); .float animstate_endtime; - METHOD(Shambler, mr_setup, bool(Shambler thismon)) + METHOD(Shambler, mr_setup, bool(Shambler thismon, entity actor)) { - SELFPARAM(); - if(!self.health) self.health = (autocvar_g_monster_shambler_health); - if(!self.attack_range) self.attack_range = 150; - if(!self.speed) { self.speed = (autocvar_g_monster_shambler_speed_walk); } - if(!self.speed2) { self.speed2 = (autocvar_g_monster_shambler_speed_run); } - if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_shambler_speed_stop); } - if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_shambler_damageforcescale); } - - self.monster_loot = spawnfunc_item_health_mega; - self.weapon = WEP_ELECTRO.m_id; // matches attacks better than WEP_VORTEX - - setanim(self, self.anim_shoot, false, true, true); - self.spawn_time = self.animstate_endtime; - self.spawnshieldtime = self.spawn_time; - self.monster_attackfunc = M_Shambler_Attack; + if(!actor.health) actor.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.weapon = WEP_ELECTRO.m_id; // matches attacks better than WEP_VORTEX + + setanim(actor, actor.anim_shoot, false, true, true); + actor.spawn_time = actor.animstate_endtime; + actor.spawnshieldtime = actor.spawn_time; + actor.monster_attackfunc = M_Shambler_Attack; return true; } diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index 0ec5f78ff4..89239941ee 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -50,7 +50,7 @@ float autocvar_g_monster_spider_attack_web_delay; float autocvar_g_monster_spider_attack_bite_damage; float autocvar_g_monster_spider_attack_bite_delay; -void M_Spider_Attack_Web(); +void M_Spider_Attack_Web(entity this); REGISTER_MUTATOR(spiderweb, true); @@ -101,7 +101,7 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity if (isPlayer) actor.enemy = Monster_FindTarget(actor); W_SetupShot_Dir(actor, v_forward, false, 0, SND(SpiderAttack_FIRE), CH_WEAPON_B, 0); if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin); - M_Spider_Attack_Web(); + M_Spider_Attack_Web(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready); return; } @@ -111,7 +111,7 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity actor.enemy = Monster_FindTarget(actor); actor.attack_range = 60; } - Monster_Attack_Melee(actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? self.anim_melee : self.anim_shoot), self.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER.m_id, true); + Monster_Attack_Melee(actor, actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? self.anim_melee : self.anim_shoot), self.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER.m_id, true); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready); } } @@ -153,14 +153,14 @@ void M_Spider_Attack_Web_Touch() void adaptor_think2use_hittype_splash(); -void M_Spider_Attack_Web() -{SELFPARAM(); - monster_makevectors(self.enemy); +void M_Spider_Attack_Web(entity this) +{ + monster_makevectors(this, this.enemy); - sound(self, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM); + sound(this, CH_SHOTS, SND_ELECTRO_FIRE2, VOL_BASE, ATTEN_NORM); entity proj = new(plasma); - proj.owner = proj.realowner = self; + proj.owner = proj.realowner = this; proj.use = M_Spider_Attack_Web_Explode; proj.think = adaptor_think2use_hittype_splash; proj.bot_dodge = true; @@ -168,7 +168,7 @@ void M_Spider_Attack_Web() proj.nextthink = time + 5; PROJECTILE_MAKETRIGGER(proj); proj.projectiledeathtype = DEATH_MONSTER_SPIDER.m_id; - setorigin(proj, CENTER_OR_VIEWOFS(self)); + setorigin(proj, CENTER_OR_VIEWOFS(this)); //proj.glow_size = 50; //proj.glow_color = 45; @@ -190,20 +190,20 @@ void M_Spider_Attack_Web() CSQCProjectile(proj, true, PROJECTILE_ELECTRO, true); } -bool M_Spider_Attack(int attack_type, entity targ) -{SELFPARAM(); +bool M_Spider_Attack(int attack_type, entity actor, entity targ) +{ .entity weaponentity = weaponentities[0]; switch(attack_type) { Weapon wep = WEP_SPIDER_ATTACK; case MONSTER_ATTACK_MELEE: { - wep.wr_think(wep, self, weaponentity, 2); + wep.wr_think(wep, actor, weaponentity, 2); return true; } case MONSTER_ATTACK_RANGED: { - wep.wr_think(wep, self, weaponentity, 1); + wep.wr_think(wep, actor, weaponentity, 1); return true; } } @@ -211,53 +211,49 @@ bool M_Spider_Attack(int attack_type, entity targ) return false; } -spawnfunc(monster_spider) { Monster_Spawn(MON_SPIDER.monsterid); } +spawnfunc(monster_spider) { Monster_Spawn(this, MON_SPIDER.monsterid); } #endif // SVQC #ifdef SVQC - METHOD(Spider, mr_think, bool(Spider thismon)) + METHOD(Spider, mr_think, bool(Spider thismon, entity actor)) { return true; } - METHOD(Spider, mr_pain, bool(Spider thismon)) + METHOD(Spider, mr_pain, bool(Spider thismon, entity actor)) { return true; } - METHOD(Spider, mr_death, bool(Spider thismon)) + METHOD(Spider, mr_death, bool(Spider thismon, entity actor)) { - SELFPARAM(); - setanim(self, self.anim_melee, false, true, true); - self.angles_x = 180; + setanim(actor, actor.anim_melee, false, true, true); + actor.angles_x = 180; return true; } #endif #ifndef MENUQC - METHOD(Spider, mr_anim, bool(Spider thismon)) + METHOD(Spider, mr_anim, bool(Spider thismon, entity actor)) { - SELFPARAM(); vector none = '0 0 0'; - self.anim_walk = animfixfps(self, '1 1 1', none); - self.anim_idle = animfixfps(self, '0 1 1', none); - self.anim_melee = animfixfps(self, '2 1 5', none); // analyze models and set framerate - self.anim_shoot = animfixfps(self, '3 1 5', none); // analyze models and set framerate - self.anim_run = animfixfps(self, '1 1 1', none); - + actor.anim_walk = animfixfps(actor, '1 1 1', none); + actor.anim_idle = animfixfps(actor, '0 1 1', none); + actor.anim_melee = animfixfps(actor, '2 1 5', none); // analyze models and set framerate + actor.anim_shoot = animfixfps(actor, '3 1 5', none); // analyze models and set framerate + actor.anim_run = animfixfps(actor, '1 1 1', none); return true; } #endif #ifdef SVQC spawnfunc(item_health_medium); - METHOD(Spider, mr_setup, bool(Spider thismon)) + METHOD(Spider, mr_setup, bool(Spider thismon, entity actor)) { - SELFPARAM(); - if(!self.health) self.health = (autocvar_g_monster_spider_health); - if(!self.speed) { self.speed = (autocvar_g_monster_spider_speed_walk); } - if(!self.speed2) { self.speed2 = (autocvar_g_monster_spider_speed_run); } - if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_spider_speed_stop); } - if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_spider_damageforcescale); } - - self.monster_loot = spawnfunc_item_health_medium; - self.monster_attackfunc = M_Spider_Attack; + if(!actor.health) actor.health = (autocvar_g_monster_spider_health); + if(!actor.speed) { actor.speed = (autocvar_g_monster_spider_speed_walk); } + if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_spider_speed_run); } + if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_spider_speed_stop); } + if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_spider_damageforcescale); } + + actor.monster_loot = spawnfunc_item_health_medium; + actor.monster_attackfunc = M_Spider_Attack; return true; } diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index 4fde5311d8..02b6a59508 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -56,7 +56,7 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity if (IS_MONSTER(actor)) { actor.attack_finished_single[0] = time + 1.2; actor.anim_finished = time + 1.2; - monster_makevectors(actor.enemy); + monster_makevectors(actor, actor.enemy); } entity missile = spawn(); @@ -119,18 +119,17 @@ void M_Wyvern_Attack_Fireball_Touch() M_Wyvern_Attack_Fireball_Explode(); } -float M_Wyvern_Attack(float attack_type, entity targ) +bool M_Wyvern_Attack(int attack_type, entity actor, entity targ) { - SELFPARAM(); .entity weaponentity = weaponentities[0]; switch(attack_type) { case MONSTER_ATTACK_MELEE: case MONSTER_ATTACK_RANGED: { - w_shotdir = normalize((self.enemy.origin + '0 0 10') - self.origin); + w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin); Weapon wep = WEP_WYVERN_ATTACK; - wep.wr_think(wep, self, weaponentity, 1); + wep.wr_think(wep, actor, weaponentity, 1); return true; } } @@ -138,59 +137,54 @@ float M_Wyvern_Attack(float attack_type, entity targ) return false; } -spawnfunc(monster_wyvern) { Monster_Spawn(MON_WYVERN.monsterid); } +spawnfunc(monster_wyvern) { Monster_Spawn(this, MON_WYVERN.monsterid); } #endif // SVQC #ifdef SVQC - METHOD(Wyvern, mr_think, bool(Wyvern thismon)) + METHOD(Wyvern, mr_think, bool(Wyvern thismon, entity actor)) { return true; } - METHOD(Wyvern, mr_pain, bool(Wyvern thismon)) + METHOD(Wyvern, mr_pain, bool(Wyvern thismon, entity actor)) { - SELFPARAM(); - self.pain_finished = time + 0.5; - setanim(self, self.anim_pain1, true, true, false); + actor.pain_finished = time + 0.5; + setanim(actor, actor.anim_pain1, true, true, false); return true; } - METHOD(Wyvern, mr_death, bool(Wyvern thismon)) + METHOD(Wyvern, mr_death, bool(Wyvern thismon, entity actor)) { - SELFPARAM(); - setanim(self, self.anim_die1, false, true, true); - self.velocity_x = -200 + 400 * random(); - self.velocity_y = -200 + 400 * random(); - self.velocity_z = 100 + 100 * random(); + setanim(actor, actor.anim_die1, false, true, true); + actor.velocity_x = -200 + 400 * random(); + actor.velocity_y = -200 + 400 * random(); + actor.velocity_z = 100 + 100 * random(); return true; } #endif #ifndef MENUQC - METHOD(Wyvern, mr_anim, bool(Wyvern thismon)) + METHOD(Wyvern, mr_anim, bool(Wyvern thismon, entity actor)) { - SELFPARAM(); vector none = '0 0 0'; - self.anim_die1 = animfixfps(self, '4 1 0.5', none); // 2 seconds - self.anim_walk = animfixfps(self, '1 1 1', none); - self.anim_idle = animfixfps(self, '0 1 1', none); - self.anim_pain1 = animfixfps(self, '3 1 2', none); // 0.5 seconds - self.anim_shoot = animfixfps(self, '2 1 5', none); // analyze models and set framerate - self.anim_run = animfixfps(self, '1 1 1', none); - + actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds + actor.anim_walk = animfixfps(actor, '1 1 1', none); + actor.anim_idle = animfixfps(actor, '0 1 1', none); + actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds + actor.anim_shoot = animfixfps(actor, '2 1 5', none); // analyze models and set framerate + actor.anim_run = animfixfps(actor, '1 1 1', none); return true; } #endif #ifdef SVQC spawnfunc(item_cells); - METHOD(Wyvern, mr_setup, bool(Wyvern thismon)) + METHOD(Wyvern, mr_setup, bool(Wyvern thismon, entity actor)) { - SELFPARAM(); - if(!self.health) self.health = (autocvar_g_monster_wyvern_health); - if(!self.speed) { self.speed = (autocvar_g_monster_wyvern_speed_walk); } - if(!self.speed2) { self.speed2 = (autocvar_g_monster_wyvern_speed_run); } - if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_wyvern_speed_stop); } - if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_wyvern_damageforcescale); } - - self.monster_loot = spawnfunc_item_cells; - self.monster_attackfunc = M_Wyvern_Attack; + if(!actor.health) actor.health = (autocvar_g_monster_wyvern_health); + if(!actor.speed) { actor.speed = (autocvar_g_monster_wyvern_speed_walk); } + if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_wyvern_speed_run); } + if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_wyvern_speed_stop); } + if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_wyvern_damageforcescale); } + + actor.monster_loot = spawnfunc_item_cells; + actor.monster_attackfunc = M_Wyvern_Attack; return true; } diff --git a/qcsrc/common/monsters/monster/zombie.qc b/qcsrc/common/monsters/monster/zombie.qc index d63188b0fe..b522a9647e 100644 --- a/qcsrc/common/monsters/monster/zombie.qc +++ b/qcsrc/common/monsters/monster/zombie.qc @@ -98,130 +98,125 @@ void M_Zombie_Attack_Leap_Touch() } } -void M_Zombie_Defend_Block_End() -{SELFPARAM(); - if(self.health <= 0) +void M_Zombie_Defend_Block_End(entity this) +{ + if(this.health <= 0) return; - setanim(self, self.anim_blockend, false, true, true); - self.armorvalue = autocvar_g_monsters_armor_blockpercent; + setanim(this, this.anim_blockend, false, true, true); + this.armorvalue = autocvar_g_monsters_armor_blockpercent; } -float M_Zombie_Defend_Block() -{SELFPARAM(); - self.armorvalue = 0.9; - self.state = MONSTER_ATTACK_MELEE; // freeze monster - self.attack_finished_single[0] = time + 2.1; - self.anim_finished = self.attack_finished_single[0]; - setanim(self, self.anim_blockstart, false, true, true); +bool M_Zombie_Defend_Block(entity this) +{ + this.armorvalue = 0.9; + this.state = MONSTER_ATTACK_MELEE; // freeze monster + this.attack_finished_single[0] = time + 2.1; + this.anim_finished = this.attack_finished_single[0]; + setanim(this, this.anim_blockstart, false, true, true); - Monster_Delay(1, 0, 2, M_Zombie_Defend_Block_End); + Monster_Delay(this, 1, 2, M_Zombie_Defend_Block_End); return true; } -float M_Zombie_Attack(float attack_type, entity targ) -{SELFPARAM(); +bool M_Zombie_Attack(int attack_type, entity actor, entity targ) +{ switch(attack_type) { case MONSTER_ATTACK_MELEE: { - if(random() < 0.3 && self.health < 75 && self.enemy.health > 10) - return M_Zombie_Defend_Block(); + if(random() < 0.3 && actor.health < 75 && actor.enemy.health > 10) + return M_Zombie_Defend_Block(actor); - float rand = random(); + float anim_chance = random(); vector chosen_anim; - if(rand < 0.33) - chosen_anim = self.anim_melee1; - else if(rand < 0.66) - chosen_anim = self.anim_melee2; + if(anim_chance < 0.33) + chosen_anim = actor.anim_melee1; + else if(anim_chance < 0.66) + chosen_anim = actor.anim_melee2; else - chosen_anim = self.anim_melee3; + chosen_anim = actor.anim_melee3; - return Monster_Attack_Melee(self.enemy, (autocvar_g_monster_zombie_attack_melee_damage), chosen_anim, self.attack_range, (autocvar_g_monster_zombie_attack_melee_delay), DEATH_MONSTER_ZOMBIE_MELEE.m_id, true); + return Monster_Attack_Melee(actor, actor.enemy, (autocvar_g_monster_zombie_attack_melee_damage), chosen_anim, actor.attack_range, (autocvar_g_monster_zombie_attack_melee_delay), DEATH_MONSTER_ZOMBIE_MELEE.m_id, true); } case MONSTER_ATTACK_RANGED: { - makevectors(self.angles); - return Monster_Attack_Leap(self.anim_shoot, M_Zombie_Attack_Leap_Touch, v_forward * (autocvar_g_monster_zombie_attack_leap_speed) + '0 0 200', (autocvar_g_monster_zombie_attack_leap_delay)); + makevectors(actor.angles); + return Monster_Attack_Leap(actor, actor.anim_shoot, M_Zombie_Attack_Leap_Touch, v_forward * (autocvar_g_monster_zombie_attack_leap_speed) + '0 0 200', (autocvar_g_monster_zombie_attack_leap_delay)); } } return false; } -spawnfunc(monster_zombie) { Monster_Spawn(MON_ZOMBIE.monsterid); } +spawnfunc(monster_zombie) { Monster_Spawn(this, MON_ZOMBIE.monsterid); } #endif // SVQC #ifdef SVQC - METHOD(Zombie, mr_think, bool(Zombie thismon)) + METHOD(Zombie, mr_think, bool(Zombie thismon, entity actor)) { - SELFPARAM(); - if(time >= self.spawn_time) - self.damageforcescale = autocvar_g_monster_zombie_damageforcescale; + if(time >= actor.spawn_time) + actor.damageforcescale = autocvar_g_monster_zombie_damageforcescale; return true; } - METHOD(Zombie, mr_pain, bool(Zombie thismon)) + METHOD(Zombie, mr_pain, bool(Zombie thismon, entity actor)) { - SELFPARAM(); - self.pain_finished = time + 0.34; - setanim(self, ((random() > 0.5) ? self.anim_pain1 : self.anim_pain2), true, true, false); + actor.pain_finished = time + 0.34; + setanim(actor, ((random() > 0.5) ? actor.anim_pain1 : actor.anim_pain2), true, true, false); return true; } - METHOD(Zombie, mr_death, bool(Zombie thismon)) + METHOD(Zombie, mr_death, bool(Zombie thismon, entity actor)) { - SELFPARAM(); - self.armorvalue = autocvar_g_monsters_armor_blockpercent; + actor.armorvalue = autocvar_g_monsters_armor_blockpercent; - setanim(self, ((random() > 0.5) ? self.anim_die1 : self.anim_die2), false, true, true); + setanim(actor, ((random() > 0.5) ? actor.anim_die1 : actor.anim_die2), false, true, true); return true; } #endif #ifndef MENUQC - METHOD(Zombie, mr_anim, bool(Zombie thismon)) + METHOD(Zombie, mr_anim, bool(Zombie thismon, entity actor)) { - SELFPARAM(); vector none = '0 0 0'; - self.anim_die1 = animfixfps(self, '9 1 0.5', none); // 2 seconds - self.anim_die2 = animfixfps(self, '12 1 0.5', none); // 2 seconds - self.anim_spawn = animfixfps(self, '30 1 3', none); - self.anim_walk = animfixfps(self, '27 1 1', none); - self.anim_idle = animfixfps(self, '19 1 1', none); - self.anim_pain1 = animfixfps(self, '20 1 2', none); // 0.5 seconds - self.anim_pain2 = animfixfps(self, '22 1 2', none); // 0.5 seconds - self.anim_melee1 = animfixfps(self, '4 1 5', none); // analyze models and set framerate - self.anim_melee2 = animfixfps(self, '4 1 5', none); // analyze models and set framerate - self.anim_melee3 = animfixfps(self, '4 1 5', none); // analyze models and set framerate - self.anim_shoot = animfixfps(self, '0 1 5', none); // analyze models and set framerate - self.anim_run = animfixfps(self, '27 1 1', none); - self.anim_blockstart = animfixfps(self, '8 1 1', none); - self.anim_blockend = animfixfps(self, '7 1 1', none); - + actor.anim_die1 = animfixfps(actor, '9 1 0.5', none); // 2 seconds + actor.anim_die2 = animfixfps(actor, '12 1 0.5', none); // 2 seconds + actor.anim_spawn = animfixfps(actor, '30 1 3', none); + actor.anim_walk = animfixfps(actor, '27 1 1', none); + actor.anim_idle = animfixfps(actor, '19 1 1', none); + actor.anim_pain1 = animfixfps(actor, '20 1 2', none); // 0.5 seconds + actor.anim_pain2 = animfixfps(actor, '22 1 2', none); // 0.5 seconds + actor.anim_melee1 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate + actor.anim_melee2 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate + actor.anim_melee3 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate + actor.anim_shoot = animfixfps(actor, '0 1 5', none); // analyze models and set framerate + actor.anim_run = animfixfps(actor, '27 1 1', none); + actor.anim_blockstart = animfixfps(actor, '8 1 1', none); + actor.anim_blockend = animfixfps(actor, '7 1 1', none); return true; } #endif #ifdef SVQC - METHOD(Zombie, mr_setup, bool(Zombie thismon)) + METHOD(Zombie, mr_setup, bool(Zombie thismon, entity actor)) { - if(!self.health) self.health = (autocvar_g_monster_zombie_health); - if(!self.speed) { self.speed = (autocvar_g_monster_zombie_speed_walk); } - if(!self.speed2) { self.speed2 = (autocvar_g_monster_zombie_speed_run); } - if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_zombie_speed_stop); } + if(!actor.health) actor.health = (autocvar_g_monster_zombie_health); + if(!actor.speed) { actor.speed = (autocvar_g_monster_zombie_speed_walk); } + if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_zombie_speed_run); } + if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_zombie_speed_stop); } - if(self.spawnflags & MONSTERFLAG_NORESPAWN) - self.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn + if(actor.spawnflags & MONSTERFLAG_NORESPAWN) + actor.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn - self.spawnflags |= MONSTER_RESPAWN_DEATHPOINT; + actor.spawnflags |= MONSTER_RESPAWN_DEATHPOINT; - self.monster_loot = spawnfunc_item_health_medium; - self.monster_attackfunc = M_Zombie_Attack; - self.spawnshieldtime = self.spawn_time; - self.respawntime = 0.2; - self.damageforcescale = 0.0001; // no push while spawning + actor.monster_loot = spawnfunc_item_health_medium; + actor.monster_attackfunc = M_Zombie_Attack; + actor.spawnshieldtime = actor.spawn_time; + actor.respawntime = 0.2; + actor.damageforcescale = 0.0001; // no push while spawning - setanim(self, self.anim_spawn, false, true, true); - self.spawn_time = self.animstate_endtime; + setanim(actor, actor.anim_spawn, false, true, true); + actor.spawn_time = actor.animstate_endtime; return true; } diff --git a/qcsrc/common/monsters/spawn.qc b/qcsrc/common/monsters/spawn.qc index e2e573d654..70459263f1 100644 --- a/qcsrc/common/monsters/spawn.qc +++ b/qcsrc/common/monsters/spawn.qc @@ -63,7 +63,7 @@ entity spawnmonster (string monster, float monster_id, entity spawnedby, entity } // Monster_Spawn checks if monster is valid - WITH(entity, self, e, Monster_Spawn(monster_id)); + Monster_Spawn(e, monster_id); return e; } diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 967757efce..e95e3d1dea 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -25,31 +25,30 @@ #include #endif -void monsters_setstatus() -{SELFPARAM(); - self.stat_monsters_total = monsters_total; - self.stat_monsters_killed = monsters_killed; +void monsters_setstatus(entity this) +{ + this.stat_monsters_total = monsters_total; + this.stat_monsters_killed = monsters_killed; } -void monster_dropitem() -{SELFPARAM(); - if(!self.candrop || !self.monster_loot) +void monster_dropitem(entity this) +{ + if(!this.candrop || !this.monster_loot) return; - vector org = self.origin + ((self.mins + self.maxs) * 0.5); + vector org = this.origin + ((this.mins + this.maxs) * 0.5); entity e = new(droppedweapon); // use weapon handling to remove it on touch e.spawnfunc_checked = true; - e.monster_loot = self.monster_loot; + e.monster_loot = this.monster_loot; MUTATOR_CALLHOOK(MonsterDropItem, e); e = other; if(e && e.monster_loot) { - setself(e); e.noalign = true; - e.monster_loot(e); + WITH(entity, self, e, e.monster_loot(e)); e.gravity = 1; e.movetype = MOVETYPE_TOSS; e.reset = SUB_Remove; @@ -57,65 +56,62 @@ void monster_dropitem() e.velocity = randomvec() * 175 + '0 0 325'; e.item_spawnshieldtime = time + 0.7; SUB_SetFade(e, time + autocvar_g_monsters_drop_time, 1); - setself(this); } } -void monster_makevectors(entity e) -{SELFPARAM(); - if(IS_MONSTER(self)) +void monster_makevectors(entity this, entity targ) +{ + if(IS_MONSTER(this)) { - vector v; - - v = e.origin + (e.mins + e.maxs) * 0.5; - self.v_angle = vectoangles(v - (self.origin + self.view_ofs)); - self.v_angle_x = -self.v_angle_x; + vector v = targ.origin + (targ.mins + targ.maxs) * 0.5; + this.v_angle = vectoangles(v - (this.origin + this.view_ofs)); + this.v_angle_x = -this.v_angle_x; } - makevectors(self.v_angle); + makevectors(this.v_angle); } // =============== // Target handling // =============== -bool Monster_ValidTarget(entity mon, entity player) -{SELFPARAM(); +bool Monster_ValidTarget(entity this, entity targ) +{ // ensure we're not checking nonexistent monster/target - if(!mon || !player) { return false; } + if(!this || !targ) { return false; } - if((player == mon) - || (autocvar_g_monsters_lineofsight && !checkpvs(mon.origin + mon.view_ofs, player)) // enemy cannot be seen - || (IS_VEHICLE(player) && !((get_monsterinfo(mon.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless + if((targ == this) + || (autocvar_g_monsters_lineofsight && !checkpvs(this.origin + this.view_ofs, targ)) // enemy cannot be seen + || (IS_VEHICLE(targ) && !((get_monsterinfo(this.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless || (time < game_starttime) // monsters do nothing before match has started - || (player.takedamage == DAMAGE_NO) - || (player.items & IT_INVISIBILITY) - || (IS_SPEC(player) || IS_OBSERVER(player)) // don't attack spectators - || (!IS_VEHICLE(player) && (IS_DEAD(player) || IS_DEAD(mon) || player.health <= 0 || mon.health <= 0)) - || (mon.monster_follow == player || player.monster_follow == mon) - || (!IS_VEHICLE(player) && (player.flags & FL_NOTARGET)) - || (!autocvar_g_monsters_typefrag && player.BUTTON_CHAT) - || (SAME_TEAM(player, mon)) - || (STAT(FROZEN, player)) - || (player.alpha != 0 && player.alpha < 0.5) + || (targ.takedamage == DAMAGE_NO) + || (targ.items & IT_INVISIBILITY) + || (IS_SPEC(targ) || IS_OBSERVER(targ)) // don't attack spectators + || (!IS_VEHICLE(targ) && (IS_DEAD(targ) || IS_DEAD(this) || targ.health <= 0 || this.health <= 0)) + || (this.monster_follow == targ || targ.monster_follow == this) + || (!IS_VEHICLE(targ) && (targ.flags & FL_NOTARGET)) + || (!autocvar_g_monsters_typefrag && targ.BUTTON_CHAT) + || (SAME_TEAM(targ, this)) + || (STAT(FROZEN, targ)) + || (targ.alpha != 0 && targ.alpha < 0.5) ) { // if any of the above checks fail, target is not valid return false; } - traceline(mon.origin + self.view_ofs, player.origin, 0, mon); + traceline(this.origin + this.view_ofs, targ.origin, 0, this); - if((trace_fraction < 1) && (trace_ent != player)) + if((trace_fraction < 1) && (trace_ent != targ)) return false; - if(autocvar_g_monsters_target_infront || (mon.spawnflags & MONSTERFLAG_INFRONT)) - if(mon.enemy != player) + if(autocvar_g_monsters_target_infront || (this.spawnflags & MONSTERFLAG_INFRONT)) + if(this.enemy != targ) { float dot; - makevectors (mon.angles); - dot = normalize (player.origin - mon.origin) * v_forward; + makevectors (this.angles); + dot = normalize (targ.origin - this.origin) * v_forward; if(dot <= autocvar_g_monsters_target_infront_range) { return false; } } @@ -194,37 +190,41 @@ void monster_changeteam(entity ent, float newteam) } } -void Monster_Delay_Action() -{SELFPARAM(); - entity oldself = self; - setself(self.owner); - if(Monster_ValidTarget(self, self.enemy)) { oldself.use(); } +.void(entity) monster_delayedfunc; +void Monster_Delay_Action_self(); +void Monster_Delay_Action(entity this) +{ + if(Monster_ValidTarget(this.owner, this.owner.enemy)) { this.monster_delayedfunc(this.owner); } - if(oldself.cnt > 0) + if(this.cnt > 1) { - oldself.cnt -= 1; - oldself.think = Monster_Delay_Action; - oldself.nextthink = time + oldself.respawn_time; + this.cnt -= 1; + this.think = Monster_Delay_Action_self; + this.nextthink = time + this.count; } else { - oldself.think = SUB_Remove_self; - oldself.nextthink = time; + this.think = SUB_Remove_self; + this.nextthink = time; } } -void Monster_Delay(float repeat_count, float repeat_defer, float defer_amnt, void() func) -{SELFPARAM(); +void Monster_Delay_Action_self() +{ + Monster_Delay_Action(self); +} + +void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func) +{ // deferred attacking, checks if monster is still alive and target is still valid before attacking entity e = spawn(); - e.think = Monster_Delay_Action; + e.think = Monster_Delay_Action_self; e.nextthink = time + defer_amnt; e.count = defer_amnt; - e.owner = self; - e.use = func; + e.owner = this; + e.monster_delayedfunc = func; e.cnt = repeat_count; - e.respawn_time = repeat_defer; } @@ -264,9 +264,9 @@ void Monster_Sound_Precache(string f) fclose(fh); } -void Monster_Sounds_Precache() -{SELFPARAM(); - string m = (get_monsterinfo(self.monsterid)).m_model.model_str(); +void Monster_Sounds_Precache(entity this) +{ + string m = (Monsters_from(this.monsterid)).m_model.model_str(); float globhandle, n, i; string f; @@ -283,9 +283,9 @@ void Monster_Sounds_Precache() search_end(globhandle); } -void Monster_Sounds_Clear() -{SELFPARAM(); -#define _MSOUND(m) if(self.monstersound_##m) { strunzone(self.monstersound_##m); self.monstersound_##m = string_null; } +void Monster_Sounds_Clear(entity this) +{ +#define _MSOUND(m) if(this.monstersound_##m) { strunzone(this.monstersound_##m); this.monstersound_##m = string_null; } ALLMONSTERSOUNDS #undef _MSOUND } @@ -303,8 +303,8 @@ void Monster_Sounds_Clear() return string_null; } -bool Monster_Sounds_Load(string f, int first) -{SELFPARAM(); +bool Monster_Sounds_Load(entity this, string f, int first) +{ float fh; string s; var .string field; @@ -321,35 +321,35 @@ bool Monster_Sounds_Load(string f, int first) field = Monster_Sound_SampleField(argv(0)); if(GetMonsterSoundSampleField_notFound) continue; - if (self.(field)) - strunzone(self.(field)); - self.(field) = strzone(strcat(argv(1), " ", argv(2))); + if (this.(field)) + strunzone(this.(field)); + this.(field) = strzone(strcat(argv(1), " ", argv(2))); } fclose(fh); return true; } .int skin_for_monstersound; -void Monster_Sounds_Update() -{SELFPARAM(); - if(self.skin == self.skin_for_monstersound) { return; } +void Monster_Sounds_Update(entity this) +{ + if(this.skin == this.skin_for_monstersound) { return; } - self.skin_for_monstersound = self.skin; - Monster_Sounds_Clear(); - if(!Monster_Sounds_Load(get_monster_model_datafilename(self.model, self.skin, "sounds"), 0)) - Monster_Sounds_Load(get_monster_model_datafilename(self.model, 0, "sounds"), 0); + this.skin_for_monstersound = this.skin; + Monster_Sounds_Clear(this); + if(!Monster_Sounds_Load(this, get_monster_model_datafilename(this.model, this.skin, "sounds"), 0)) + Monster_Sounds_Load(this, get_monster_model_datafilename(this.model, 0, "sounds"), 0); } -void Monster_Sound(.string samplefield, float sound_delay, float delaytoo, float chan) -{SELFPARAM(); +void Monster_Sound(entity this, .string samplefield, float sound_delay, float delaytoo, float chan) +{ if(!autocvar_g_monsters_sounds) { return; } if(delaytoo) - if(time < self.msound_delay) + if(time < this.msound_delay) return; // too early - GlobalSound_string(self, self.(samplefield), chan, VOICETYPE_PLAYERSOUND); + GlobalSound_string(this, this.(samplefield), chan, VOICETYPE_PLAYERSOUND); - self.msound_delay = time + sound_delay; + this.msound_delay = time + sound_delay; } @@ -357,94 +357,94 @@ void Monster_Sound(.string samplefield, float sound_delay, float delaytoo, float // Monster attack handlers // ======================= -float Monster_Attack_Melee(entity targ, float damg, vector anim, float er, float animtime, int deathtype, float dostop) -{SELFPARAM(); - if(dostop && (self.flags & FL_MONSTER)) { self.state = MONSTER_ATTACK_MELEE; } +bool Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, bool dostop) +{ + if(dostop && IS_MONSTER(this)) { this.state = MONSTER_ATTACK_MELEE; } - setanim(self, anim, false, true, false); + setanim(this, anim, false, true, false); - if(self.animstate_endtime > time && (self.flags & FL_MONSTER)) - self.attack_finished_single[0] = self.anim_finished = self.animstate_endtime; + if(this.animstate_endtime > time && IS_MONSTER(this)) + this.attack_finished_single[0] = this.anim_finished = this.animstate_endtime; else - self.attack_finished_single[0] = self.anim_finished = time + animtime; + this.attack_finished_single[0] = this.anim_finished = time + animtime; - monster_makevectors(targ); + monster_makevectors(this, targ); - traceline(self.origin + self.view_ofs, self.origin + v_forward * er, 0, self); + traceline(this.origin + this.view_ofs, this.origin + v_forward * er, 0, this); if(trace_ent.takedamage) - Damage(trace_ent, self, self, damg * MONSTER_SKILLMOD(self), deathtype, trace_ent.origin, normalize(trace_ent.origin - self.origin)); + Damage(trace_ent, this, this, damg * MONSTER_SKILLMOD(this), deathtype, trace_ent.origin, normalize(trace_ent.origin - this.origin)); return true; } -float Monster_Attack_Leap_Check(vector vel) -{SELFPARAM(); - if(self.state && (self.flags & FL_MONSTER)) +bool Monster_Attack_Leap_Check(entity this, vector vel) +{ + if(this.state && IS_MONSTER(this)) return false; // already attacking - if(!(IS_ONGROUND(self))) + if(!IS_ONGROUND(this)) return false; // not on the ground - if(self.health <= 0) + if(this.health <= 0 || IS_DEAD(this)) return false; // called when dead? - if(time < self.attack_finished_single[0]) + if(time < this.attack_finished_single[0]) return false; // still attacking - vector old = self.velocity; + vector old = this.velocity; - self.velocity = vel; - tracetoss(self, self); - self.velocity = old; - if (trace_ent != self.enemy) + this.velocity = vel; + tracetoss(this, this); + this.velocity = old; + if (trace_ent != this.enemy) return false; return true; } -bool Monster_Attack_Leap(vector anm, void() touchfunc, vector vel, float animtime) -{SELFPARAM(); - if(!Monster_Attack_Leap_Check(vel)) +bool Monster_Attack_Leap(entity this, vector anm, void() touchfunc, vector vel, float animtime) +{ + if(!Monster_Attack_Leap_Check(this, vel)) return false; - setanim(self, anm, false, true, false); + setanim(this, anm, false, true, false); - if(self.animstate_endtime > time && (self.flags & FL_MONSTER)) - self.attack_finished_single[0] = self.anim_finished = self.animstate_endtime; + if(this.animstate_endtime > time && (this.flags & FL_MONSTER)) + this.attack_finished_single[0] = this.anim_finished = this.animstate_endtime; else - self.attack_finished_single[0] = self.anim_finished = time + animtime; + this.attack_finished_single[0] = this.anim_finished = time + animtime; - if(self.flags & FL_MONSTER) - self.state = MONSTER_ATTACK_RANGED; - self.touch = touchfunc; - self.origin_z += 1; - self.velocity = vel; - UNSET_ONGROUND(self); + if(this.flags & FL_MONSTER) + this.state = MONSTER_ATTACK_RANGED; + this.touch = touchfunc; + this.origin_z += 1; + this.velocity = vel; + UNSET_ONGROUND(this); return true; } -void Monster_Attack_Check(entity e, entity targ) +void Monster_Attack_Check(entity this, entity targ) { - if((e == world || targ == world) - || (!e.monster_attackfunc) - || (time < e.attack_finished_single[0]) + if((this == world || targ == world) + || (!this.monster_attackfunc) + || (time < this.attack_finished_single[0]) ) { return; } - float targ_vlen = vlen(targ.origin - e.origin); + float targ_vlen = vlen(targ.origin - this.origin); - if(targ_vlen <= e.attack_range) + if(targ_vlen <= this.attack_range) { - float attack_success = e.monster_attackfunc(MONSTER_ATTACK_MELEE, targ); + bool attack_success = this.monster_attackfunc(MONSTER_ATTACK_MELEE, this, targ); if(attack_success == 1) - Monster_Sound(monstersound_melee, 0, false, CH_VOICE); + Monster_Sound(this, monstersound_melee, 0, false, CH_VOICE); else if(attack_success > 0) return; } - if(targ_vlen > e.attack_range) + if(targ_vlen > this.attack_range) { - float attack_success = e.monster_attackfunc(MONSTER_ATTACK_RANGED, targ); + float attack_success = this.monster_attackfunc(MONSTER_ATTACK_RANGED, this, targ); if(attack_success == 1) - Monster_Sound(monstersound_melee, 0, false, CH_VOICE); + Monster_Sound(this, monstersound_melee, 0, false, CH_VOICE); else if(attack_success > 0) return; } @@ -455,23 +455,23 @@ void Monster_Attack_Check(entity e, entity targ) // Main monster functions // ====================== -void Monster_UpdateModel() -{SELFPARAM(); +void Monster_UpdateModel(entity this) +{ // assume some defaults - /*self.anim_idle = animfixfps(self, '0 1 0.01', '0 0 0'); - self.anim_walk = animfixfps(self, '1 1 0.01', '0 0 0'); - self.anim_run = animfixfps(self, '2 1 0.01', '0 0 0'); - self.anim_fire1 = animfixfps(self, '3 1 0.01', '0 0 0'); - self.anim_fire2 = animfixfps(self, '4 1 0.01', '0 0 0'); - self.anim_melee = animfixfps(self, '5 1 0.01', '0 0 0'); - self.anim_pain1 = animfixfps(self, '6 1 0.01', '0 0 0'); - self.anim_pain2 = animfixfps(self, '7 1 0.01', '0 0 0'); - self.anim_die1 = animfixfps(self, '8 1 0.01', '0 0 0'); - self.anim_die2 = animfixfps(self, '9 1 0.01', '0 0 0');*/ + /*this.anim_idle = animfixfps(this, '0 1 0.01', '0 0 0'); + this.anim_walk = animfixfps(this, '1 1 0.01', '0 0 0'); + this.anim_run = animfixfps(this, '2 1 0.01', '0 0 0'); + this.anim_fire1 = animfixfps(this, '3 1 0.01', '0 0 0'); + this.anim_fire2 = animfixfps(this, '4 1 0.01', '0 0 0'); + this.anim_melee = animfixfps(this, '5 1 0.01', '0 0 0'); + this.anim_pain1 = animfixfps(this, '6 1 0.01', '0 0 0'); + this.anim_pain2 = animfixfps(this, '7 1 0.01', '0 0 0'); + this.anim_die1 = animfixfps(this, '8 1 0.01', '0 0 0'); + this.anim_die2 = animfixfps(this, '9 1 0.01', '0 0 0');*/ // then get the real values - Monster mon = get_monsterinfo(self.monsterid); - mon.mr_anim(mon); + Monster mon = get_monsterinfo(this.monsterid); + mon.mr_anim(mon, this); } void Monster_Touch() @@ -485,30 +485,30 @@ void Monster_Touch() self.enemy = other; } -void Monster_Miniboss_Check() -{SELFPARAM(); - if(MUTATOR_CALLHOOK(MonsterCheckBossFlag)) +void Monster_Miniboss_Check(entity this) +{ + if(MUTATOR_CALLHOOK(MonsterCheckBossFlag, this)) return; float chance = random() * 100; // g_monsters_miniboss_chance cvar or spawnflags 64 causes a monster to be a miniboss - if ((self.spawnflags & MONSTERFLAG_MINIBOSS) || (chance < autocvar_g_monsters_miniboss_chance)) + if ((this.spawnflags & MONSTERFLAG_MINIBOSS) || (chance < autocvar_g_monsters_miniboss_chance)) { - self.health += autocvar_g_monsters_miniboss_healthboost; - self.effects |= EF_RED; - if(!self.weapon) - self.weapon = WEP_VORTEX.m_id; + this.health += autocvar_g_monsters_miniboss_healthboost; + this.effects |= EF_RED; + if(!this.weapon) + this.weapon = WEP_VORTEX.m_id; } } -bool Monster_Respawn_Check() -{SELFPARAM(); - if(self.deadflag == DEAD_DEAD) // don't call when monster isn't dead - if(MUTATOR_CALLHOOK(MonsterRespawn, self)) +bool Monster_Respawn_Check(entity this) +{ + if(this.deadflag == DEAD_DEAD) // don't call when monster isn't dead + if(MUTATOR_CALLHOOK(MonsterRespawn, this)) return true; // enabled by a mutator - if(self.spawnflags & MONSTERFLAG_NORESPAWN) + if(this.spawnflags & MONSTERFLAG_NORESPAWN) return false; if(!autocvar_g_monsters_respawn) @@ -517,35 +517,35 @@ bool Monster_Respawn_Check() return true; } -void Monster_Respawn() { SELFPARAM(); Monster_Spawn(self.monsterid); } +void Monster_Respawn() { SELFPARAM(); Monster_Spawn(self, self.monsterid); } -void Monster_Dead_Fade() -{SELFPARAM(); - if(Monster_Respawn_Check()) +void Monster_Dead_Fade(entity this) +{ + if(Monster_Respawn_Check(this)) { - self.spawnflags |= MONSTERFLAG_RESPAWNED; - self.think = Monster_Respawn; - self.nextthink = time + self.respawntime; - self.monster_lifetime = 0; - self.deadflag = DEAD_RESPAWNING; - if(self.spawnflags & MONSTER_RESPAWN_DEATHPOINT) + this.spawnflags |= MONSTERFLAG_RESPAWNED; + this.think = Monster_Respawn; + this.nextthink = time + this.respawntime; + this.monster_lifetime = 0; + this.deadflag = DEAD_RESPAWNING; + if(this.spawnflags & MONSTER_RESPAWN_DEATHPOINT) { - self.pos1 = self.origin; - self.pos2 = self.angles; + this.pos1 = this.origin; + this.pos2 = this.angles; } - self.event_damage = func_null; - self.takedamage = DAMAGE_NO; - setorigin(self, self.pos1); - self.angles = self.pos2; - self.health = self.max_health; - setmodel(self, MDL_Null); + this.event_damage = func_null; + this.takedamage = DAMAGE_NO; + setorigin(this, this.pos1); + this.angles = this.pos2; + this.health = this.max_health; + setmodel(this, MDL_Null); } else { // number of monsters spawned with mobspawn command totalspawned -= 1; - SUB_SetFade(self, time + 3, 1); + SUB_SetFade(this, time + 3, 1); } } @@ -554,102 +554,102 @@ void Monster_Use() if(Monster_ValidTarget(self, activator)) { self.enemy = activator; } } -vector Monster_Move_Target(entity targ) -{SELFPARAM(); +vector Monster_Move_Target(entity this, entity targ) +{ // enemy is always preferred target - if(self.enemy) + if(this.enemy) { - vector targ_origin = ((self.enemy.absmin + self.enemy.absmax) * 0.5); - targ_origin = WarpZone_RefSys_TransformOrigin(self.enemy, self, targ_origin); // origin of target as seen by the monster (us) - WarpZone_TraceLine(self.origin, targ_origin, MOVE_NOMONSTERS, self); - - if((self.enemy == world) - || (IS_DEAD(self.enemy) || self.enemy.health < 1) - || (STAT(FROZEN, self.enemy)) - || (self.enemy.flags & FL_NOTARGET) - || (self.enemy.alpha < 0.5 && self.enemy.alpha != 0) - || (self.enemy.takedamage == DAMAGE_NO) - || (vlen(self.origin - targ_origin) > self.target_range) - || ((trace_fraction < 1) && (trace_ent != self.enemy))) + vector targ_origin = ((this.enemy.absmin + this.enemy.absmax) * 0.5); + targ_origin = WarpZone_RefSys_TransformOrigin(this.enemy, this, targ_origin); // origin of target as seen by the monster (us) + WarpZone_TraceLine(this.origin, targ_origin, MOVE_NOMONSTERS, this); + + if((this.enemy == world) + || (IS_DEAD(this.enemy) || this.enemy.health < 1) + || (STAT(FROZEN, this.enemy)) + || (this.enemy.flags & FL_NOTARGET) + || (this.enemy.alpha < 0.5 && this.enemy.alpha != 0) + || (this.enemy.takedamage == DAMAGE_NO) + || (vlen(this.origin - targ_origin) > this.target_range) + || ((trace_fraction < 1) && (trace_ent != this.enemy))) { - self.enemy = world; - self.pass_distance = 0; + this.enemy = world; + this.pass_distance = 0; } - if(self.enemy) + if(this.enemy) { - /*WarpZone_TrailParticles(world, particleeffectnum(EFFECT_RED_PASS), self.origin, targ_origin); + /*WarpZone_TrailParticles(world, particleeffectnum(EFFECT_RED_PASS), this.origin, targ_origin); print("Trace origin: ", vtos(targ_origin), "\n"); - print("Target origin: ", vtos(self.enemy.origin), "\n"); - print("My origin: ", vtos(self.origin), "\n"); */ + print("Target origin: ", vtos(this.enemy.origin), "\n"); + print("My origin: ", vtos(this.origin), "\n"); */ - self.monster_movestate = MONSTER_MOVE_ENEMY; - self.last_trace = time + 1.2; - if(self.monster_moveto) - return self.monster_moveto; // assumes code is properly setting this when monster has an enemy + this.monster_movestate = MONSTER_MOVE_ENEMY; + this.last_trace = time + 1.2; + if(this.monster_moveto) + return this.monster_moveto; // assumes code is properly setting this when monster has an enemy else return targ_origin; } - /*makevectors(self.angles); - self.monster_movestate = MONSTER_MOVE_ENEMY; - self.last_trace = time + 1.2; - return self.enemy.origin; */ + /*makevectors(this.angles); + this.monster_movestate = MONSTER_MOVE_ENEMY; + this.last_trace = time + 1.2; + return this.enemy.origin; */ } - switch(self.monster_moveflags) + switch(this.monster_moveflags) { case MONSTER_MOVE_FOLLOW: { - self.monster_movestate = MONSTER_MOVE_FOLLOW; - self.last_trace = time + 0.3; - return (self.monster_follow) ? self.monster_follow.origin : self.origin; + this.monster_movestate = MONSTER_MOVE_FOLLOW; + this.last_trace = time + 0.3; + return (this.monster_follow) ? this.monster_follow.origin : this.origin; } case MONSTER_MOVE_SPAWNLOC: { - self.monster_movestate = MONSTER_MOVE_SPAWNLOC; - self.last_trace = time + 2; - return self.pos1; + this.monster_movestate = MONSTER_MOVE_SPAWNLOC; + this.last_trace = time + 2; + return this.pos1; } case MONSTER_MOVE_NOMOVE: { - if(self.monster_moveto) + if(this.monster_moveto) { - self.last_trace = time + 0.5; - return self.monster_moveto; + this.last_trace = time + 0.5; + return this.monster_moveto; } else { - self.monster_movestate = MONSTER_MOVE_NOMOVE; - self.last_trace = time + 2; + this.monster_movestate = MONSTER_MOVE_NOMOVE; + this.last_trace = time + 2; } - return self.origin; + return this.origin; } default: case MONSTER_MOVE_WANDER: { vector pos; - self.monster_movestate = MONSTER_MOVE_WANDER; + this.monster_movestate = MONSTER_MOVE_WANDER; - if(self.monster_moveto) + if(this.monster_moveto) { - self.last_trace = time + 0.5; - pos = self.monster_moveto; + this.last_trace = time + 0.5; + pos = this.monster_moveto; } else if(targ) { - self.last_trace = time + 0.5; + this.last_trace = time + 0.5; pos = targ.origin; } else { - self.last_trace = time + self.wander_delay; + this.last_trace = time + this.wander_delay; - self.angles_y = rint(random() * 500); - makevectors(self.angles); - pos = self.origin + v_forward * self.wander_distance; + this.angles_y = rint(random() * 500); + makevectors(this.angles); + pos = this.origin + v_forward * this.wander_distance; - if(((self.flags & FL_FLY) && (self.spawnflags & MONSTERFLAG_FLY_VERTICAL)) || (self.flags & FL_SWIM)) + if(((this.flags & FL_FLY) && (this.spawnflags & MONSTERFLAG_FLY_VERTICAL)) || (this.flags & FL_SWIM)) { pos.z = random() * 200; if(random() >= 0.5) @@ -662,259 +662,259 @@ vector Monster_Move_Target(entity targ) } } -void Monster_CalculateVelocity(entity mon, vector to, vector from, float turnrate, float movespeed) -{SELFPARAM(); +void Monster_CalculateVelocity(entity this, vector to, vector from, float turnrate, float movespeed) +{ float current_distance = vlen((('1 0 0' * to.x) + ('0 1 0' * to.y)) - (('1 0 0' * from.x) + ('0 1 0' * from.y))); // for the sake of this check, exclude Z axis float initial_height = 0; //min(50, (targ_distance * tanh(20))); - float current_height = (initial_height * min(1, (self.pass_distance) ? (current_distance / self.pass_distance) : current_distance)); + float current_height = (initial_height * min(1, (this.pass_distance) ? (current_distance / this.pass_distance) : current_distance)); //print("current_height = ", ftos(current_height), ", initial_height = ", ftos(initial_height), ".\n"); vector targpos; if(current_height) // make sure we can actually do this arcing path { targpos = (to + ('0 0 1' * current_height)); - WarpZone_TraceLine(mon.origin, targpos, MOVE_NOMONSTERS, mon); + WarpZone_TraceLine(this.origin, targpos, MOVE_NOMONSTERS, this); if(trace_fraction < 1) { //print("normal arc line failed, trying to find new pos..."); - WarpZone_TraceLine(to, targpos, MOVE_NOMONSTERS, mon); + WarpZone_TraceLine(to, targpos, MOVE_NOMONSTERS, this); targpos = (trace_endpos + '0 0 -10'); - WarpZone_TraceLine(mon.origin, targpos, MOVE_NOMONSTERS, mon); + WarpZone_TraceLine(this.origin, targpos, MOVE_NOMONSTERS, this); if(trace_fraction < 1) { targpos = to; /* print(" ^1FAILURE^7, reverting to original direction.\n"); */ } /*else { print(" ^3SUCCESS^7, using new arc line.\n"); } */ } } else { targpos = to; } - //mon.angles = normalize(('0 1 0' * to_y) - ('0 1 0' * from_y)); + //this.angles = normalize(('0 1 0' * to_y) - ('0 1 0' * from_y)); vector desired_direction = normalize(targpos - from); - if(turnrate) { mon.velocity = (normalize(normalize(mon.velocity) + (desired_direction * 50)) * movespeed); } - else { mon.velocity = (desired_direction * movespeed); } + if(turnrate) { this.velocity = (normalize(normalize(this.velocity) + (desired_direction * 50)) * movespeed); } + else { this.velocity = (desired_direction * movespeed); } - //mon.steerto = steerlib_attract2(targpos, 0.5, 500, 0.95); - //mon.angles = vectoangles(mon.velocity); + //this.steerto = steerlib_attract2(targpos, 0.5, 500, 0.95); + //this.angles = vectoangles(this.velocity); } -void Monster_Move(float runspeed, float walkspeed, float stpspeed) -{SELFPARAM(); - if(self.target2) { self.goalentity = find(world, targetname, self.target2); } +void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed) +{ + if(this.target2) { this.goalentity = find(world, targetname, this.target2); } entity targ; - if(STAT(FROZEN, self) == 2) + if(STAT(FROZEN, this) == 2) { - self.revive_progress = bound(0, self.revive_progress + self.ticrate * self.revive_speed, 1); - self.health = max(1, self.revive_progress * self.max_health); - self.iceblock.alpha = bound(0.2, 1 - self.revive_progress, 1); + this.revive_progress = bound(0, this.revive_progress + this.ticrate * this.revive_speed, 1); + this.health = max(1, this.revive_progress * this.max_health); + this.iceblock.alpha = bound(0.2, 1 - this.revive_progress, 1); - if(!(self.spawnflags & MONSTERFLAG_INVINCIBLE) && self.sprite) - WaypointSprite_UpdateHealth(self.sprite, self.health); + if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite) + WaypointSprite_UpdateHealth(this.sprite, this.health); - movelib_brake_simple(stpspeed); - setanim(self, self.anim_idle, true, false, false); + movelib_brake_simple(this, stpspeed); + setanim(this, this.anim_idle, true, false, false); - self.enemy = world; - self.nextthink = time + self.ticrate; + this.enemy = world; + this.nextthink = time + this.ticrate; - if(self.revive_progress >= 1) - Unfreeze(self); + if(this.revive_progress >= 1) + Unfreeze(this); return; } - else if(STAT(FROZEN, self) == 3) + else if(STAT(FROZEN, this) == 3) { - self.revive_progress = bound(0, self.revive_progress - self.ticrate * self.revive_speed, 1); - self.health = max(0, autocvar_g_nades_ice_health + (self.max_health-autocvar_g_nades_ice_health) * self.revive_progress ); + this.revive_progress = bound(0, this.revive_progress - this.ticrate * this.revive_speed, 1); + this.health = max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * this.revive_progress ); - if(!(self.spawnflags & MONSTERFLAG_INVINCIBLE) && self.sprite) - WaypointSprite_UpdateHealth(self.sprite, self.health); + if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite) + WaypointSprite_UpdateHealth(this.sprite, this.health); - movelib_brake_simple(stpspeed); - setanim(self, self.anim_idle, true, false, false); + movelib_brake_simple(this, stpspeed); + setanim(this, this.anim_idle, true, false, false); - self.enemy = world; - self.nextthink = time + self.ticrate; + this.enemy = world; + this.nextthink = time + this.ticrate; - if(self.health < 1) + if(this.health < 1) { - Unfreeze(self); - self.health = 0; - if(self.event_damage) - self.event_damage(self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, self.origin, '0 0 0'); + Unfreeze(this); + this.health = 0; + if(this.event_damage) + this.event_damage(this, this.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, this.origin, '0 0 0'); } - else if ( self.revive_progress <= 0 ) - Unfreeze(self); + else if ( this.revive_progress <= 0 ) + Unfreeze(this); return; } - if(self.flags & FL_SWIM) + if(this.flags & FL_SWIM) { - if(self.waterlevel < WATERLEVEL_WETFEET) + if(this.waterlevel < WATERLEVEL_WETFEET) { - if(time >= self.last_trace) + if(time >= this.last_trace) { - self.last_trace = time + 0.4; + this.last_trace = time + 0.4; - Damage (self, world, world, 2, DEATH_DROWN.m_id, self.origin, '0 0 0'); - self.angles = '90 90 0'; + Damage (this, world, world, 2, DEATH_DROWN.m_id, this.origin, '0 0 0'); + this.angles = '90 90 0'; if(random() < 0.5) { - self.velocity_y += random() * 50; - self.velocity_x -= random() * 50; + this.velocity_y += random() * 50; + this.velocity_x -= random() * 50; } else { - self.velocity_y -= random() * 50; - self.velocity_x += random() * 50; + this.velocity_y -= random() * 50; + this.velocity_x += random() * 50; } - self.velocity_z += random() * 150; + this.velocity_z += random() * 150; } - self.movetype = MOVETYPE_BOUNCE; - //self.velocity_z = -200; + this.movetype = MOVETYPE_BOUNCE; + //this.velocity_z = -200; return; } - else if(self.movetype == MOVETYPE_BOUNCE) + else if(this.movetype == MOVETYPE_BOUNCE) { - self.angles_x = 0; - self.movetype = MOVETYPE_WALK; + this.angles_x = 0; + this.movetype = MOVETYPE_WALK; } } - targ = self.goalentity; + targ = this.goalentity; - if (MUTATOR_CALLHOOK(MonsterMove, runspeed, walkspeed, targ) + if (MUTATOR_CALLHOOK(MonsterMove, this, runspeed, walkspeed, targ) || gameover - || self.draggedby != world + || this.draggedby != world || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || time < game_starttime || (autocvar_g_campaign && !campaign_bots_may_start) - || time < self.spawn_time) + || time < this.spawn_time) { runspeed = walkspeed = 0; - if(time >= self.spawn_time) - setanim(self, self.anim_idle, true, false, false); - movelib_brake_simple(stpspeed); + if(time >= this.spawn_time) + setanim(this, this.anim_idle, true, false, false); + movelib_brake_simple(this, stpspeed); return; } targ = monster_target; - runspeed = bound(0, monster_speed_run * MONSTER_SKILLMOD(self), runspeed * 2.5); // limit maxspeed to prevent craziness - walkspeed = bound(0, monster_speed_walk * MONSTER_SKILLMOD(self), walkspeed * 2.5); // limit maxspeed to prevent craziness + runspeed = bound(0, monster_speed_run * MONSTER_SKILLMOD(this), runspeed * 2.5); // limit maxspeed to prevent craziness + walkspeed = bound(0, monster_speed_walk * MONSTER_SKILLMOD(this), walkspeed * 2.5); // limit maxspeed to prevent craziness if(teamplay) if(autocvar_g_monsters_teams) - if(DIFF_TEAM(self.monster_follow, self)) - self.monster_follow = world; + if(DIFF_TEAM(this.monster_follow, this)) + this.monster_follow = world; - if(time >= self.last_enemycheck) + if(time >= this.last_enemycheck) { - if(!self.enemy) + if(!this.enemy) { - self.enemy = Monster_FindTarget(self); - if(self.enemy) + this.enemy = Monster_FindTarget(this); + if(this.enemy) { - WarpZone_RefSys_Copy(self.enemy, self); - WarpZone_RefSys_AddInverse(self.enemy, self); // wz1^-1 ... wzn^-1 receiver - self.moveto = WarpZone_RefSys_TransformOrigin(self.enemy, self, (0.5 * (self.enemy.absmin + self.enemy.absmax))); - self.monster_moveto = '0 0 0'; - self.monster_face = '0 0 0'; - - self.pass_distance = vlen((('1 0 0' * self.enemy.origin_x) + ('0 1 0' * self.enemy.origin_y)) - (('1 0 0' * self.origin_x) + ('0 1 0' * self.origin_y))); - Monster_Sound(monstersound_sight, 0, false, CH_VOICE); + WarpZone_RefSys_Copy(this.enemy, this); + WarpZone_RefSys_AddInverse(this.enemy, this); // wz1^-1 ... wzn^-1 receiver + this.moveto = WarpZone_RefSys_TransformOrigin(this.enemy, this, (0.5 * (this.enemy.absmin + this.enemy.absmax))); + this.monster_moveto = '0 0 0'; + this.monster_face = '0 0 0'; + + this.pass_distance = vlen((('1 0 0' * this.enemy.origin_x) + ('0 1 0' * this.enemy.origin_y)) - (('1 0 0' * this.origin_x) + ('0 1 0' * this.origin_y))); + Monster_Sound(this, monstersound_sight, 0, false, CH_VOICE); } } - self.last_enemycheck = time + 1; // check for enemies every second + this.last_enemycheck = time + 1; // check for enemies every second } - if(self.state == MONSTER_ATTACK_RANGED && (IS_ONGROUND(self))) + if(this.state == MONSTER_ATTACK_RANGED && IS_ONGROUND(this)) { - self.state = 0; - self.touch = Monster_Touch; + this.state = 0; + this.touch = Monster_Touch; } - if(self.state && time >= self.attack_finished_single[0]) - self.state = 0; // attack is over + if(this.state && time >= this.attack_finished_single[0]) + this.state = 0; // attack is over - if(self.state != MONSTER_ATTACK_MELEE) // don't move if set - if(time >= self.last_trace || self.enemy) // update enemy or rider instantly - self.moveto = Monster_Move_Target(targ); + if(this.state != MONSTER_ATTACK_MELEE) // don't move if set + if(time >= this.last_trace || this.enemy) // update enemy or rider instantly + this.moveto = Monster_Move_Target(this, targ); - if(!self.enemy) - Monster_Sound(monstersound_idle, 7, true, CH_VOICE); + if(!this.enemy) + Monster_Sound(this, monstersound_idle, 7, true, CH_VOICE); - if(self.state == MONSTER_ATTACK_MELEE) - self.moveto = self.origin; + if(this.state == MONSTER_ATTACK_MELEE) + this.moveto = this.origin; - if(self.enemy && self.enemy.vehicle) + if(this.enemy && this.enemy.vehicle) runspeed = 0; - if(!(self.spawnflags & MONSTERFLAG_FLY_VERTICAL) && !(self.flags & FL_SWIM)) - self.moveto_z = self.origin_z; + if(!(this.spawnflags & MONSTERFLAG_FLY_VERTICAL) && !(this.flags & FL_SWIM)) + this.moveto_z = this.origin_z; - if(vlen(self.origin - self.moveto) > 100) + if(vlen(this.origin - this.moveto) > 100) { - float do_run = (self.enemy || self.monster_moveto); - if((IS_ONGROUND(self)) || ((self.flags & FL_FLY) || (self.flags & FL_SWIM))) - Monster_CalculateVelocity(self, self.moveto, self.origin, true, ((do_run) ? runspeed : walkspeed)); - - if(time > self.pain_finished) // TODO: use anim_finished instead! - if(!self.state) - if(time > self.anim_finished) - if(vlen(self.velocity) > 10) - setanim(self, ((do_run) ? self.anim_run : self.anim_walk), true, false, false); + float do_run = (this.enemy || this.monster_moveto); + if(IS_ONGROUND(this) || ((this.flags & FL_FLY) || (this.flags & FL_SWIM))) + Monster_CalculateVelocity(this, this.moveto, this.origin, true, ((do_run) ? runspeed : walkspeed)); + + if(time > this.pain_finished) // TODO: use anim_finished instead! + if(!this.state) + if(time > this.anim_finished) + if(vlen(this.velocity) > 10) + setanim(this, ((do_run) ? this.anim_run : this.anim_walk), true, false, false); else - setanim(self, self.anim_idle, true, false, false); + setanim(this, this.anim_idle, true, false, false); } else { - entity e = find(world, targetname, self.target2); + entity e = find(world, targetname, this.target2); if(e.target2) - self.target2 = e.target2; + this.target2 = e.target2; else if(e.target) - self.target2 = e.target; - - movelib_brake_simple(stpspeed); - if(time > self.anim_finished) - if(time > self.pain_finished) - if(!self.state) - if(vlen(self.velocity) <= 30) - setanim(self, self.anim_idle, true, false, false); + this.target2 = e.target; + + movelib_brake_simple(this, stpspeed); + if(time > this.anim_finished) + if(time > this.pain_finished) + if(!this.state) + if(vlen(this.velocity) <= 30) + setanim(this, this.anim_idle, true, false, false); } - self.steerto = steerlib_attract2(((self.monster_face) ? self.monster_face : self.moveto), 0.5, 500, 0.95); + this.steerto = steerlib_attract2(this, ((this.monster_face) ? this.monster_face : this.moveto), 0.5, 500, 0.95); - vector real_angle = vectoangles(self.steerto) - self.angles; + vector real_angle = vectoangles(this.steerto) - this.angles; float turny = 25; - if(self.state == MONSTER_ATTACK_MELEE) + if(this.state == MONSTER_ATTACK_MELEE) turny = 0; if(turny) { - turny = bound(turny * -1, shortangle_f(real_angle.y, self.angles.y), turny); - self.angles_y += turny; + turny = bound(turny * -1, shortangle_f(real_angle.y, this.angles.y), turny); + this.angles_y += turny; } - Monster_Attack_Check(self, self.enemy); + Monster_Attack_Check(this, this.enemy); } -void Monster_Remove(entity mon) +void Monster_Remove(entity this) { .entity weaponentity = weaponentities[0]; - if(!mon) { return; } + if(!this) { return; } - if(!MUTATOR_CALLHOOK(MonsterRemove, mon)) - Send_Effect(EFFECT_ITEM_PICKUP, mon.origin, '0 0 0', 1); + if(!MUTATOR_CALLHOOK(MonsterRemove, this)) + Send_Effect(EFFECT_ITEM_PICKUP, this.origin, '0 0 0', 1); - if(mon.(weaponentity)) { remove(mon.(weaponentity)); } - if(mon.iceblock) { remove(mon.iceblock); } - WaypointSprite_Kill(mon.sprite); - remove(mon); + if(this.(weaponentity)) { remove(this.(weaponentity)); } + if(this.iceblock) { remove(this.iceblock); } + WaypointSprite_Kill(this.sprite); + remove(this); } void Monster_Dead_Think() @@ -924,7 +924,7 @@ void Monster_Dead_Think() if(self.monster_lifetime != 0) if(time >= self.monster_lifetime) { - Monster_Dead_Fade(); + Monster_Dead_Fade(self); return; } } @@ -933,19 +933,19 @@ void Monster_Appear() {SELFPARAM(); self.enemy = activator; self.spawnflags &= ~MONSTERFLAG_APPEAR; // otherwise, we get an endless loop - Monster_Spawn(self.monsterid); + Monster_Spawn(self, self.monsterid); } -float Monster_Appear_Check(entity ent, float monster_id) +bool Monster_Appear_Check(entity this, int monster_id) { - if(!(ent.spawnflags & MONSTERFLAG_APPEAR)) + if(!(this.spawnflags & MONSTERFLAG_APPEAR)) return false; - ent.think = func_null; - ent.monsterid = monster_id; // set so this monster is properly registered (otherwise, normal initialization is used) - ent.nextthink = 0; - ent.use = Monster_Appear; - ent.flags = FL_MONSTER; // set so this monster can get butchered + this.think = func_null; + this.monsterid = monster_id; // set so this monster is properly registered (otherwise, normal initialization is used) + this.nextthink = 0; + this.use = Monster_Appear; + this.flags = FL_MONSTER; // set so this monster can get butchered return true; } @@ -984,27 +984,27 @@ void Monster_Dead_Damage(entity inflictor, entity attacker, float damage, int de } } -void Monster_Dead(entity attacker, float gibbed) -{SELFPARAM(); - self.think = Monster_Dead_Think; - self.nextthink = time; - self.monster_lifetime = time + 5; +void Monster_Dead(entity this, entity attacker, float gibbed) +{ + this.think = Monster_Dead_Think; + this.nextthink = time; + this.monster_lifetime = time + 5; - if(STAT(FROZEN, self)) + if(STAT(FROZEN, this)) { - Unfreeze(self); // remove any icy remains - self.health = 0; // reset by Unfreeze + Unfreeze(this); // remove any icy remains + this.health = 0; // reset by Unfreeze } - monster_dropitem(); + monster_dropitem(this); - Monster_Sound(monstersound_death, 0, false, CH_VOICE); + Monster_Sound(this, monstersound_death, 0, false, CH_VOICE); - if(!(self.spawnflags & MONSTERFLAG_SPAWNED) && !(self.spawnflags & MONSTERFLAG_RESPAWNED)) + if(!(this.spawnflags & MONSTERFLAG_SPAWNED) && !(this.spawnflags & MONSTERFLAG_RESPAWNED)) monsters_killed += 1; if(IS_PLAYER(attacker)) - if(autocvar_g_monsters_score_spawned || !((self.spawnflags & MONSTERFLAG_SPAWNED) || (self.spawnflags & MONSTERFLAG_RESPAWNED))) + if(autocvar_g_monsters_score_spawned || !((this.spawnflags & MONSTERFLAG_SPAWNED) || (this.spawnflags & MONSTERFLAG_RESPAWNED))) PlayerScore_Add(attacker, SP_SCORE, +autocvar_g_monsters_score_kill); if(gibbed) @@ -1013,29 +1013,29 @@ void Monster_Dead(entity attacker, float gibbed) totalspawned -= 1; } - self.event_damage = ((gibbed) ? func_null : Monster_Dead_Damage); - self.solid = SOLID_CORPSE; - self.takedamage = DAMAGE_AIM; - self.deadflag = DEAD_DEAD; - self.enemy = world; - self.movetype = MOVETYPE_TOSS; - self.moveto = self.origin; - self.touch = Monster_Touch; // reset incase monster was pouncing - self.reset = func_null; - self.state = 0; - self.attack_finished_single[0] = 0; - self.effects = 0; + this.event_damage = ((gibbed) ? func_null : Monster_Dead_Damage); + this.solid = SOLID_CORPSE; + this.takedamage = DAMAGE_AIM; + this.deadflag = DEAD_DEAD; + this.enemy = world; + this.movetype = MOVETYPE_TOSS; + this.moveto = this.origin; + this.touch = Monster_Touch; // reset incase monster was pouncing + this.reset = func_null; + this.state = 0; + this.attack_finished_single[0] = 0; + this.effects = 0; - if(!((self.flags & FL_FLY) || (self.flags & FL_SWIM))) - self.velocity = '0 0 0'; + if(!((this.flags & FL_FLY) || (this.flags & FL_SWIM))) + this.velocity = '0 0 0'; - CSQCModel_UnlinkEntity(self); + CSQCModel_UnlinkEntity(this); - Monster mon = get_monsterinfo(self.monsterid); - mon.mr_death(mon); + Monster mon = get_monsterinfo(this.monsterid); + mon.mr_death(mon, this); - if(self.candrop && self.weapon) - W_ThrowNewWeapon(self, self.weapon, 0, self.origin, randomvec() * 150 + '0 0 325'); + if(this.candrop && this.weapon) + W_ThrowNewWeapon(this, this.weapon, 0, this.origin, randomvec() * 150 + '0 0 325'); } void Monster_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) @@ -1066,13 +1066,13 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty frag_attacker = attacker; frag_deathtype = deathtype; Monster mon = get_monsterinfo(self.monsterid); - mon.mr_pain(mon); + mon.mr_pain(mon, self); take = damage_take; if(take) { self.health -= take; - Monster_Sound(monstersound_pain, 1.2, true, CH_PAIN); + Monster_Sound(self, monstersound_pain, 1.2, true, CH_PAIN); } if(self.sprite) @@ -1105,7 +1105,7 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty SUB_UseTargets(); self.target2 = self.oldtarget2; // reset to original target on death, incase we respawn - Monster_Dead(attacker, (self.health <= -100 || deathtype == DEATH_KILL.m_id)); + Monster_Dead(self, attacker, (self.health <= -100 || deathtype == DEATH_KILL.m_id)); WaypointSprite_Kill(self.sprite); @@ -1123,25 +1123,25 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty } // don't check for enemies, just keep walking in a straight line -void Monster_Move_2D(float mspeed, float allow_jumpoff) -{SELFPARAM(); - if(gameover || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || self.draggedby != world || time < game_starttime || (autocvar_g_campaign && !campaign_bots_may_start) || time < self.spawn_time) +void Monster_Move_2D(entity this, float mspeed, bool allow_jumpoff) +{ + if(gameover || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || this.draggedby != world || time < game_starttime || (autocvar_g_campaign && !campaign_bots_may_start) || time < this.spawn_time) { mspeed = 0; - if(time >= self.spawn_time) - setanim(self, self.anim_idle, true, false, false); - movelib_brake_simple(0.6); + if(time >= this.spawn_time) + setanim(this, this.anim_idle, true, false, false); + movelib_brake_simple(this, 0.6); return; } float reverse = false; vector a, b; - makevectors(self.angles); - a = self.origin + '0 0 16'; - b = self.origin + '0 0 16' + v_forward * 32; + makevectors(this.angles); + a = this.origin + '0 0 16'; + b = this.origin + '0 0 16' + v_forward * 32; - traceline(a, b, MOVE_NORMAL, self); + traceline(a, b, MOVE_NORMAL, this); if(trace_fraction != 1.0) { @@ -1157,31 +1157,31 @@ void Monster_Move_2D(float mspeed, float allow_jumpoff) if(!allow_jumpoff) { a = b - '0 0 32'; - traceline(b, a, MOVE_WORLDONLY, self); + traceline(b, a, MOVE_WORLDONLY, this); if(trace_fraction == 1.0) reverse = true; } */ if(reverse) { - self.angles_y = anglemods(self.angles_y - 180); - makevectors(self.angles); + this.angles_y = anglemods(this.angles_y - 180); + makevectors(this.angles); } - movelib_move_simple_gravity(v_forward, mspeed, 1); + movelib_move_simple_gravity(this, v_forward, mspeed, 1); - if(time > self.pain_finished) - if(time > self.attack_finished_single[0]) - if(vlen(self.velocity) > 10) - setanim(self, self.anim_walk, true, false, false); + if(time > this.pain_finished) + if(time > this.attack_finished_single[0]) + if(vlen(this.velocity) > 10) + setanim(this, this.anim_walk, true, false, false); else - setanim(self, self.anim_idle, true, false, false); + setanim(this, this.anim_idle, true, false, false); } -void Monster_Anim() -{SELFPARAM(); - int deadbits = (self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2)); - if(IS_DEAD(self)) +void Monster_Anim(entity this) +{ + int deadbits = (this.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2)); + if(IS_DEAD(this)) { if (!deadbits) { @@ -1198,19 +1198,19 @@ void Monster_Anim() deadbits = 0; } int animbits = deadbits; - if(STAT(FROZEN, self)) + if(STAT(FROZEN, this)) animbits |= ANIMSTATE_FROZEN; - if(self.crouch) + if(this.crouch) animbits |= ANIMSTATE_DUCK; // not that monsters can crouch currently... - animdecide_setstate(self, animbits, false); - animdecide_setimplicitstate(self, (IS_ONGROUND(self))); + animdecide_setstate(this, animbits, false); + animdecide_setimplicitstate(this, (IS_ONGROUND(this))); /* // weapon entities for monsters? - if (self.weaponentity) + if (this.weaponentity) { - updateanim(self.weaponentity); - if (!self.weaponentity.animstate_override) - setanim(self.weaponentity, self.weaponentity.anim_idle, true, false, false); + updateanim(this.weaponentity); + if (!this.weaponentity.animstate_override) + setanim(this.weaponentity, this.weaponentity.anim_idle, true, false, false); } */ } @@ -1228,181 +1228,181 @@ void Monster_Think() } Monster mon = get_monsterinfo(self.monsterid); - if(mon.mr_think(mon)) - Monster_Move(self.speed2, self.speed, self.stopspeed); + if(mon.mr_think(mon, self)) + Monster_Move(self, self.speed2, self.speed, self.stopspeed); - Monster_Anim(); + Monster_Anim(self); CSQCMODEL_AUTOUPDATE(self); } -float Monster_Spawn_Setup() -{SELFPARAM(); - Monster mon = get_monsterinfo(self.monsterid); - mon.mr_setup(mon); +bool Monster_Spawn_Setup(entity this) +{ + Monster mon = Monsters_from(this.monsterid); + mon.mr_setup(mon, this); // ensure some basic needs are met - if(!self.health) { self.health = 100; } - if(!self.armorvalue) { self.armorvalue = bound(0.2, 0.5 * MONSTER_SKILLMOD(self), 0.9); } - if(!self.target_range) { self.target_range = autocvar_g_monsters_target_range; } - if(!self.respawntime) { self.respawntime = autocvar_g_monsters_respawn_delay; } - if(!self.monster_moveflags) { self.monster_moveflags = MONSTER_MOVE_WANDER; } - if(!self.attack_range) { self.attack_range = autocvar_g_monsters_attack_range; } - if(!self.damageforcescale) { self.damageforcescale = autocvar_g_monsters_damageforcescale; } - - if(!(self.spawnflags & MONSTERFLAG_RESPAWNED)) + if(!this.health) { this.health = 100; } + if(!this.armorvalue) { this.armorvalue = bound(0.2, 0.5 * MONSTER_SKILLMOD(this), 0.9); } + if(!this.target_range) { this.target_range = autocvar_g_monsters_target_range; } + if(!this.respawntime) { this.respawntime = autocvar_g_monsters_respawn_delay; } + if(!this.monster_moveflags) { this.monster_moveflags = MONSTER_MOVE_WANDER; } + if(!this.attack_range) { this.attack_range = autocvar_g_monsters_attack_range; } + if(!this.damageforcescale) { this.damageforcescale = autocvar_g_monsters_damageforcescale; } + + if(!(this.spawnflags & MONSTERFLAG_RESPAWNED)) { - Monster_Miniboss_Check(); - self.health *= MONSTER_SKILLMOD(self); + Monster_Miniboss_Check(this); + this.health *= MONSTER_SKILLMOD(this); - if(!self.skin) - self.skin = rint(random() * 4); + if(!this.skin) + this.skin = rint(random() * 4); } - self.max_health = self.health; - self.pain_finished = self.nextthink; + this.max_health = this.health; + this.pain_finished = this.nextthink; - if(IS_PLAYER(self.monster_follow)) - self.effects |= EF_DIMLIGHT; + if(IS_PLAYER(this.monster_follow)) + this.effects |= EF_DIMLIGHT; - if(!self.wander_delay) { self.wander_delay = 2; } - if(!self.wander_distance) { self.wander_distance = 600; } + if(!this.wander_delay) { this.wander_delay = 2; } + if(!this.wander_distance) { this.wander_distance = 600; } - Monster_Sounds_Precache(); - Monster_Sounds_Update(); + Monster_Sounds_Precache(this); + Monster_Sounds_Update(this); if(teamplay) - self.monster_attack = true; // we can have monster enemies in team games + this.monster_attack = true; // we can have monster enemies in team games - Monster_Sound(monstersound_spawn, 0, false, CH_VOICE); + Monster_Sound(this, monstersound_spawn, 0, false, CH_VOICE); if(autocvar_g_monsters_healthbars) { - entity wp = WaypointSprite_Spawn(WP_Monster, 0, 1024, self, '0 0 1' * (self.maxs.z + 15), world, self.team, self, sprite, true, RADARICON_DANGER); - wp.wp_extra = self.monsterid; - wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0 0'); - if(!(self.spawnflags & MONSTERFLAG_INVINCIBLE)) + entity wp = WaypointSprite_Spawn(WP_Monster, 0, 1024, this, '0 0 1' * (this.maxs.z + 15), world, this.team, this, sprite, true, RADARICON_DANGER); + wp.wp_extra = this.monsterid; + wp.colormod = ((this.team) ? Team_ColorRGB(this.team) : '1 0 0'); + if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE)) { - WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health); - WaypointSprite_UpdateHealth(self.sprite, self.health); + WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health); + WaypointSprite_UpdateHealth(this.sprite, this.health); } } - self.think = Monster_Think; - self.nextthink = time + self.ticrate; + this.think = Monster_Think; + this.nextthink = time + this.ticrate; - if(MUTATOR_CALLHOOK(MonsterSpawn)) + if(MUTATOR_CALLHOOK(MonsterSpawn, this)) return false; return true; } -bool Monster_Spawn(int mon_id) -{SELFPARAM(); +bool Monster_Spawn(entity this, int mon_id) +{ // setup the basic required properties for a monster - entity mon = get_monsterinfo(mon_id); + entity mon = Monsters_from(mon_id); if(!mon.monsterid) { return false; } // invalid monster - if(!autocvar_g_monsters) { Monster_Remove(self); return false; } + if(!autocvar_g_monsters) { Monster_Remove(this); return false; } - if(Monster_Appear_Check(self, mon_id)) { return true; } // return true so the monster isn't removed + if(Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed - if(!self.monster_skill) - self.monster_skill = cvar("g_monsters_skill"); + if(!this.monster_skill) + this.monster_skill = cvar("g_monsters_skill"); // support for quake style removing monsters based on skill - if(self.monster_skill == MONSTER_SKILL_EASY) if(self.spawnflags & MONSTERSKILL_NOTEASY) { Monster_Remove(self); return false; } - if(self.monster_skill == MONSTER_SKILL_MEDIUM) if(self.spawnflags & MONSTERSKILL_NOTMEDIUM) { Monster_Remove(self); return false; } - if(self.monster_skill == MONSTER_SKILL_HARD) if(self.spawnflags & MONSTERSKILL_NOTHARD) { Monster_Remove(self); return false; } + if(this.monster_skill == MONSTER_SKILL_EASY) if(this.spawnflags & MONSTERSKILL_NOTEASY) { Monster_Remove(this); return false; } + if(this.monster_skill == MONSTER_SKILL_MEDIUM) if(this.spawnflags & MONSTERSKILL_NOTMEDIUM) { Monster_Remove(this); return false; } + if(this.monster_skill == MONSTER_SKILL_HARD) if(this.spawnflags & MONSTERSKILL_NOTHARD) { Monster_Remove(this); return false; } - if(self.team && !teamplay) - self.team = 0; + if(this.team && !teamplay) + this.team = 0; - if(!(self.spawnflags & MONSTERFLAG_SPAWNED)) // naturally spawned monster - if(!(self.spawnflags & MONSTERFLAG_RESPAWNED)) // don't count re-spawning monsters either + if(!(this.spawnflags & MONSTERFLAG_SPAWNED)) // naturally spawned monster + if(!(this.spawnflags & MONSTERFLAG_RESPAWNED)) // don't count re-spawning monsters either monsters_total += 1; - setmodel(self, mon.m_model); - self.flags = FL_MONSTER; - self.classname = "monster"; - self.takedamage = DAMAGE_AIM; - self.bot_attack = true; - self.iscreature = true; - self.teleportable = true; - self.damagedbycontents = true; - self.monsterid = mon_id; - self.event_damage = Monster_Damage; - self.touch = Monster_Touch; - self.use = Monster_Use; - self.solid = SOLID_BBOX; - self.movetype = MOVETYPE_WALK; - self.spawnshieldtime = time + autocvar_g_monsters_spawnshieldtime; - self.enemy = world; - self.velocity = '0 0 0'; - self.moveto = self.origin; - self.pos1 = self.origin; - self.pos2 = self.angles; - self.reset = Monster_Reset; - self.netname = mon.netname; - self.monster_attackfunc = mon.monster_attackfunc; - self.monster_name = mon.monster_name; - self.candrop = true; - self.view_ofs = '0 0 0.7' * (self.maxs_z * 0.5); - self.oldtarget2 = self.target2; - self.pass_distance = 0; - self.deadflag = DEAD_NO; - self.noalign = ((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM)); - self.spawn_time = time; - self.gravity = 1; - self.monster_moveto = '0 0 0'; - self.monster_face = '0 0 0'; - self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP; - - if(!self.scale) { self.scale = 1; } - if(autocvar_g_monsters_edit) { self.grab = 1; } - if(autocvar_g_fullbrightplayers) { self.effects |= EF_FULLBRIGHT; } - if(autocvar_g_nodepthtestplayers) { self.effects |= EF_NODEPTHTEST; } - if(mon.spawnflags & MONSTER_TYPE_SWIM) { self.flags |= FL_SWIM; } + setmodel(this, mon.m_model); + this.flags = FL_MONSTER; + this.classname = "monster"; + this.takedamage = DAMAGE_AIM; + this.bot_attack = true; + this.iscreature = true; + this.teleportable = true; + this.damagedbycontents = true; + this.monsterid = mon_id; + this.event_damage = Monster_Damage; + this.touch = Monster_Touch; + this.use = Monster_Use; + this.solid = SOLID_BBOX; + this.movetype = MOVETYPE_WALK; + this.spawnshieldtime = time + autocvar_g_monsters_spawnshieldtime; + this.enemy = world; + this.velocity = '0 0 0'; + this.moveto = this.origin; + this.pos1 = this.origin; + this.pos2 = this.angles; + this.reset = Monster_Reset; + this.netname = mon.netname; + this.monster_attackfunc = mon.monster_attackfunc; + this.monster_name = mon.monster_name; + this.candrop = true; + this.view_ofs = '0 0 0.7' * (this.maxs_z * 0.5); + this.oldtarget2 = this.target2; + this.pass_distance = 0; + this.deadflag = DEAD_NO; + this.noalign = ((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM)); + this.spawn_time = time; + this.gravity = 1; + this.monster_moveto = '0 0 0'; + this.monster_face = '0 0 0'; + this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP; + + if(!this.scale) { this.scale = 1; } + if(autocvar_g_monsters_edit) { this.grab = 1; } + if(autocvar_g_fullbrightplayers) { this.effects |= EF_FULLBRIGHT; } + if(autocvar_g_nodepthtestplayers) { this.effects |= EF_NODEPTHTEST; } + if(mon.spawnflags & MONSTER_TYPE_SWIM) { this.flags |= FL_SWIM; } if(mon.spawnflags & MONSTER_TYPE_FLY) { - self.flags |= FL_FLY; - self.movetype = MOVETYPE_FLY; + this.flags |= FL_FLY; + this.movetype = MOVETYPE_FLY; } - if(!(self.spawnflags & MONSTERFLAG_RESPAWNED)) + if(!(this.spawnflags & MONSTERFLAG_RESPAWNED)) { if(mon.spawnflags & MONSTER_SIZE_BROKEN) - self.scale *= 1.3; + this.scale *= 1.3; if(mon.spawnflags & MONSTER_SIZE_QUAKE) if(autocvar_g_monsters_quake_resize) - self.scale *= 1.3; + this.scale *= 1.3; } - setsize(self, mon.mins * self.scale, mon.maxs * self.scale); + setsize(this, mon.mins * this.scale, mon.maxs * this.scale); - self.ticrate = bound(sys_frametime, ((!self.ticrate) ? autocvar_g_monsters_think_delay : self.ticrate), 60); + this.ticrate = bound(sys_frametime, ((!this.ticrate) ? autocvar_g_monsters_think_delay : this.ticrate), 60); - Monster_UpdateModel(); + Monster_UpdateModel(this); - if(!Monster_Spawn_Setup()) + if(!Monster_Spawn_Setup(this)) { - Monster_Remove(self); + Monster_Remove(this); return false; } - if(!self.noalign) + if(!this.noalign) { - setorigin(self, self.origin + '0 0 20'); - tracebox(self.origin + '0 0 64', self.mins, self.maxs, self.origin - '0 0 10000', MOVE_WORLDONLY, self); - setorigin(self, trace_endpos); + setorigin(this, this.origin + '0 0 20'); + tracebox(this.origin + '0 0 64', this.mins, this.maxs, this.origin - '0 0 10000', MOVE_WORLDONLY, this); + setorigin(this, trace_endpos); } - if(!(self.spawnflags & MONSTERFLAG_RESPAWNED)) - monster_setupcolors(self); + if(!(this.spawnflags & MONSTERFLAG_RESPAWNED)) + monster_setupcolors(this); - CSQCMODEL_AUTOINIT(self); + CSQCMODEL_AUTOINIT(this); return true; } diff --git a/qcsrc/common/monsters/sv_monsters.qh b/qcsrc/common/monsters/sv_monsters.qh index bad6242bc5..59d8cbd973 100644 --- a/qcsrc/common/monsters/sv_monsters.qh +++ b/qcsrc/common/monsters/sv_monsters.qh @@ -69,29 +69,29 @@ const int MONSTERFLAG_RESPAWNED = 32768; // flag for re-spawned monsters .int monster_skill; // functions used elsewhere -void Monster_Remove(entity mon); +void Monster_Remove(entity this); -void monsters_setstatus(); +void monsters_setstatus(entity this); -bool Monster_Spawn(int mon_id); +bool Monster_Spawn(entity this, int mon_id); -void monster_setupcolors(entity mon); +void monster_setupcolors(entity this); void Monster_Touch(); -void Monster_Move_2D(float mspeed, float allow_jumpoff); +void Monster_Move_2D(entity this, float mspeed, float allow_jumpoff); -void Monster_Delay(float repeat_count, float repeat_defer, float defer_amnt, void() func); +void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func); -float Monster_Attack_Melee(entity targ, float damg, vector anim, float er, float animtime, int deathtype, float dostop); +float Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, float dostop); -bool Monster_Attack_Leap(vector anm, void() touchfunc, vector vel, float animtime); +bool Monster_Attack_Leap(entity this, vector anm, void() touchfunc, vector vel, float animtime); -entity Monster_FindTarget(entity mon); +entity Monster_FindTarget(entity this); -void monster_makevectors(entity e); +void monster_makevectors(entity this, entity targ); -void Monster_Sound(.string samplefield, float sound_delay, float delaytoo, float chan); +void Monster_Sound(entity this, .string samplefield, float sound_delay, float delaytoo, float chan); /** number of monsters spawned with mobspawn command */ int totalspawned; diff --git a/qcsrc/common/physics/movelib.qc b/qcsrc/common/physics/movelib.qc index 207b4c636d..26c70daf60 100644 --- a/qcsrc/common/physics/movelib.qc +++ b/qcsrc/common/physics/movelib.qc @@ -163,17 +163,17 @@ void movelib_update(vector dir,float force) } */ -void movelib_brake_simple(float force) -{SELFPARAM(); +void movelib_brake_simple(entity this, float force) +{ float mspeed; vector mdir; float vz; - mspeed = max(0,vlen(self.velocity) - force); - mdir = normalize(self.velocity); - vz = self.velocity.z; - self.velocity = mdir * mspeed; - self.velocity_z = vz; + mspeed = max(0,vlen(this.velocity) - force); + mdir = normalize(this.velocity); + vz = this.velocity.z; + this.velocity = mdir * mspeed; + this.velocity_z = vz; } /** diff --git a/qcsrc/common/physics/movelib.qh b/qcsrc/common/physics/movelib.qh index 26b7033ff3..86cb733850 100644 --- a/qcsrc/common/physics/movelib.qh +++ b/qcsrc/common/physics/movelib.qh @@ -34,13 +34,13 @@ void movelib_move_simple(vector newdir,float velo,float blendrate) self.velocity = self.velocity * (1 - blendrate) + (newdir * blendrate) * velo; } */ -#define movelib_move_simple(newdir,velo,blendrate) \ - self.velocity = self.velocity * (1 - blendrate) + (newdir * blendrate) * velo +#define movelib_move_simple(e,newdir,velo,blendrate) \ + e.velocity = e.velocity * (1 - blendrate) + (newdir * blendrate) * velo -#define movelib_move_simple_gravity(newdir,velo,blendrate) \ - if(IS_ONGROUND(self)) movelib_move_simple(newdir,velo,blendrate) +#define movelib_move_simple_gravity(e,newdir,velo,blendrate) \ + if(IS_ONGROUND(e)) movelib_move_simple(e,newdir,velo,blendrate) -void movelib_brake_simple(float force); +void movelib_brake_simple(entity this, float force); /** Pitches and rolls the entity to match the gound. diff --git a/qcsrc/common/turrets/turret/ewheel.qc b/qcsrc/common/turrets/turret/ewheel.qc index b681df1056..e81666fd3f 100644 --- a/qcsrc/common/turrets/turret/ewheel.qc +++ b/qcsrc/common/turrets/turret/ewheel.qc @@ -75,9 +75,9 @@ void ewheel_move_path() { self.moveto = self.pathcurrent.origin; - self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95); + self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95); - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); } } @@ -94,29 +94,29 @@ void ewheel_move_enemy() if ( self.tur_head.spawnshieldtime < 1 ) { newframe = ewheel_anim_fwd_fast; - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); } else if (self.tur_head.spawnshieldtime < 2) { newframe = ewheel_anim_fwd_slow; - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); } else { newframe = ewheel_anim_fwd_slow; - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slower), 0.4); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_slower), 0.4); } } else if (self.tur_dist_enemy < self.target_range_optimal * 0.5) { newframe = ewheel_anim_bck_slow; - movelib_move_simple(v_forward * -1, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); + movelib_move_simple(self, v_forward * -1, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); } else { newframe = ewheel_anim_stop; - movelib_brake_simple((autocvar_g_turrets_unit_ewheel_speed_stop)); + movelib_brake_simple(self, (autocvar_g_turrets_unit_ewheel_speed_stop)); } turrets_setframe(newframe, false); @@ -132,7 +132,7 @@ void ewheel_move_idle() self.frame = 0; if (vlen(self.velocity)) - movelib_brake_simple((autocvar_g_turrets_unit_ewheel_speed_stop)); + movelib_brake_simple(self, (autocvar_g_turrets_unit_ewheel_speed_stop)); } spawnfunc(turret_ewheel) { if(!turret_initialize(TUR_EWHEEL)) remove(self); } diff --git a/qcsrc/common/turrets/turret/walker.qc b/qcsrc/common/turrets/turret/walker.qc index 6f19e35cb1..05f2b77ed4 100644 --- a/qcsrc/common/turrets/turret/walker.qc +++ b/qcsrc/common/turrets/turret/walker.qc @@ -114,7 +114,7 @@ void walker_rocket_damage (entity inflictor, entity attacker, float damage, floa W_PrepareExplosionByDamage(self.owner, walker_rocket_explode); } -#define WALKER_ROCKET_MOVE movelib_move_simple(newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(self) +#define WALKER_ROCKET_MOVE movelib_move_simple(self, newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(self) void walker_rocket_loop(); void walker_rocket_think() {SELFPARAM(); @@ -292,7 +292,7 @@ void walker_move_to(vector _target, float _dist) } self.moveto = _target; - self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95); + self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95); if(self.enemy) { @@ -330,7 +330,7 @@ void walker_move_path() self.pathcurrent = self.pathcurrent.path_next; self.moveto = self.pathcurrent.origin; - self.steerto = steerlib_attract2(self.moveto,0.5,500,0.95); + self.steerto = steerlib_attract2(self, self.moveto,0.5,500,0.95); walker_move_to(self.moveto, 0); #else @@ -341,7 +341,7 @@ void walker_move_path() return; self.moveto = self.pathcurrent.origin; - self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95); + self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95); walker_move_to(self.moveto, 0); #endif } @@ -424,7 +424,7 @@ spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(self); } if (fabs(wish_angle_y) < 15) { self.moveto = self.enemy.origin; - self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95); + self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95); self.animflag = ANIM_MELEE; } } @@ -470,32 +470,32 @@ spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(self); } switch (self.animflag) { case ANIM_NO: - movelib_brake_simple((autocvar_g_turrets_unit_walker_speed_stop)); + movelib_brake_simple(self, (autocvar_g_turrets_unit_walker_speed_stop)); break; case ANIM_TURN: turny = (autocvar_g_turrets_unit_walker_turn); - movelib_brake_simple((autocvar_g_turrets_unit_walker_speed_stop)); + movelib_brake_simple(self, (autocvar_g_turrets_unit_walker_speed_stop)); break; case ANIM_WALK: turny = (autocvar_g_turrets_unit_walker_turn_walk); - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_walker_speed_walk), 0.6); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_walker_speed_walk), 0.6); break; case ANIM_RUN: turny = (autocvar_g_turrets_unit_walker_turn_run); - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_walker_speed_run), 0.6); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_walker_speed_run), 0.6); break; case ANIM_STRAFE_L: turny = (autocvar_g_turrets_unit_walker_turn_strafe); - movelib_move_simple(v_right * -1, (autocvar_g_turrets_unit_walker_speed_walk), 0.8); + movelib_move_simple(self, v_right * -1, (autocvar_g_turrets_unit_walker_speed_walk), 0.8); break; case ANIM_STRAFE_R: turny = (autocvar_g_turrets_unit_walker_turn_strafe); - movelib_move_simple(v_right, (autocvar_g_turrets_unit_walker_speed_walk), 0.8); + movelib_move_simple(self, v_right, (autocvar_g_turrets_unit_walker_speed_walk), 0.8); break; case ANIM_JUMP: @@ -518,7 +518,7 @@ spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(self); } defer(self, 0.21, walker_melee_do_dmg); } - movelib_brake_simple((autocvar_g_turrets_unit_walker_speed_stop)); + movelib_brake_simple(self, (autocvar_g_turrets_unit_walker_speed_stop)); break; case ANIM_SWIM: @@ -526,13 +526,13 @@ spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(self); } turnx = (autocvar_g_turrets_unit_walker_turn_swim); self.angles_x += bound(-10, shortangle_f(real_angle_x, self.angles_x), 10); - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_walker_speed_swim), 0.3); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_walker_speed_swim), 0.3); vz = self.velocity_z + sin(time * 4) * 8; break; case ANIM_ROAM: turny = (autocvar_g_turrets_unit_walker_turn_walk); - movelib_move_simple(v_forward ,(autocvar_g_turrets_unit_walker_speed_roam), 0.5); + movelib_move_simple(self, v_forward ,(autocvar_g_turrets_unit_walker_speed_roam), 0.5); break; } diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index dcf8eaec32..0004667cdb 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -192,7 +192,7 @@ float spiderbot_frame() //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n"); sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM); } - movelib_brake_simple(autocvar_g_vehicle_spiderbot_speed_stop); + movelib_brake_simple(self, autocvar_g_vehicle_spiderbot_speed_stop); spider.frame = 5; } } @@ -224,7 +224,7 @@ float spiderbot_frame() } player.movement_y = 0; float oldvelz = spider.velocity_z; - movelib_move_simple(normalize(v_forward * player.movement_x),((player.BUTTON_JUMP) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia); + movelib_move_simple(self, normalize(v_forward * player.movement_x),((player.BUTTON_JUMP) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia); spider.velocity_z = oldvelz; float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1); if(spider.velocity_z <= 20) // not while jumping @@ -254,7 +254,7 @@ float spiderbot_frame() } float oldvelz = spider.velocity_z; - movelib_move_simple(normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia); + movelib_move_simple(self, normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia); spider.velocity_z = oldvelz; float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1); if(spider.velocity_z <= 20) // not while jumping @@ -576,7 +576,7 @@ spawnfunc(vehicle_spiderbot) METHOD(Spiderbot, vr_think, void(Spiderbot thisveh, entity instance)) { if(IS_ONGROUND(self)) - movelib_brake_simple(autocvar_g_vehicle_spiderbot_speed_stop); + movelib_brake_simple(self, autocvar_g_vehicle_spiderbot_speed_stop); } METHOD(Spiderbot, vr_death, void(Spiderbot thisveh, entity instance)) { diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 2d0908ff5f..9230f0c248 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2397,7 +2397,7 @@ void PlayerPreThink () secrets_setstatus(); // monsters status - monsters_setstatus(); + monsters_setstatus(self); self.dmg_team = max(0, self.dmg_team - autocvar_g_teamdamage_resetspeed * frametime); diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index bff80c7cec..93b87ad979 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -215,7 +215,10 @@ MUTATOR_HOOKABLE(GetCvars, EV_NO_ARGS); // NOTE: Can't use EV_GetCvars because o MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile); /** called when a monster spawns */ -MUTATOR_HOOKABLE(MonsterSpawn, EV_NO_ARGS); +#define EV_MonsterSpawn(i, o) \ + /**/ i(entity, __self) \ + /**/ +MUTATOR_HOOKABLE(MonsterSpawn, EV_MonsterSpawn); /** called when a monster dies */ #define EV_MonsterDies(i, o) \ @@ -249,6 +252,7 @@ MUTATOR_HOOKABLE(MonsterDropItem, EV_MonsterDropItem); * returning true makes the monster stop */ #define EV_MonsterMove(i, o) \ + /**/ i(entity, __self) \ /**/ i(float, monster_speed_run) \ /**/ o(float, monster_speed_run) \ /**/ i(float, monster_speed_walk) \ @@ -264,7 +268,10 @@ MUTATOR_HOOKABLE(MonsterMove, EV_MonsterMove); MUTATOR_HOOKABLE(MonsterFindTarget, EV_NO_ARGS); /** called to change a random monster to a miniboss */ -MUTATOR_HOOKABLE(MonsterCheckBossFlag, EV_NO_ARGS); +#define EV_MonsterCheckBossFlag(i, o) \ + /**/ i(entity, __self) \ + /**/ +MUTATOR_HOOKABLE(MonsterCheckBossFlag, EV_MonsterCheckBossFlag); /** * called when a player tries to spawn a monster diff --git a/qcsrc/server/steerlib.qc b/qcsrc/server/steerlib.qc index beaab08a4d..ae850618d8 100644 --- a/qcsrc/server/steerlib.qc +++ b/qcsrc/server/steerlib.qc @@ -48,14 +48,14 @@ vector steerlib_attract(vector point, float maximal_distance) return direction * (1-(distance / maximal_distance)); } -vector steerlib_attract2(vector point, float min_influense,float max_distance,float max_influense) -{SELFPARAM(); +vector steerlib_attract2(entity this, vector point, float min_influense,float max_distance,float max_influense) +{ float distance; vector direction; float influense; - distance = bound(0.00001,vlen(self.origin - point),max_distance); - direction = normalize(point - self.origin); + distance = bound(0.00001,vlen(this.origin - point),max_distance); + direction = normalize(point - this.origin); influense = 1 - (distance / max_distance); influense = min_influense + (influense * (max_influense - min_influense)); diff --git a/qcsrc/server/steerlib.qh b/qcsrc/server/steerlib.qh index fcd35ba783..3c10bfd027 100644 --- a/qcsrc/server/steerlib.qh +++ b/qcsrc/server/steerlib.qh @@ -4,7 +4,7 @@ .vector steerto; vector steerlib_arrive(vector point,float maximal_distance); -vector steerlib_attract2(vector point, float min_influense,float max_distance,float max_influense); +vector steerlib_attract2(entity this, vector point, float min_influense,float max_distance,float max_influense); vector steerlib_pull(vector point); #endif diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index 96062375af..01a23c1a5c 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -53,7 +53,8 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m if (IS_PLAYER(ent) && accuracy_canbegooddamage(ent)) accuracy_add(ent, PS(ent).m_weapon.m_id, maxdamage, 0); - W_HitPlotAnalysis(ent, v_forward, v_right, v_up); + if(IS_PLAYER(ent)) + W_HitPlotAnalysis(ent, v_forward, v_right, v_up); .entity weaponentity = weaponentities[0]; // TODO: unhardcode vector md = ent.(weaponentity).movedir;