]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/monster/mage.qc
Weapons: add a second .weaponentity
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / mage.qc
index fd1c9bb85212d136bcee44aebabbad3cb8c1e3f1..b63c0f73e5e64171f8532ce4d73e94661234d13b 100644 (file)
@@ -41,20 +41,20 @@ REGISTER_WEAPON(MAGE_SPIKE, NEW(MageSpike));
 
 void M_Mage_Attack_Spike(vector dir);
 void M_Mage_Attack_Push();
-METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, bool fire1, bool fire2)) {
-    if (fire1)
-    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, false, 0.2)) {
+METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, int slot, int fire)) {
+    if (fire & 1)
+    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, slot, false, 0.2)) {
         if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range;
         actor.enemy = Monster_FindTarget(actor);
         W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_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);
-        weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready);
+        weapon_thinkf(actor, slot, WFRAME_FIRE1, 0, w_ready);
     }
-    if (fire2)
-    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, true, 0.5)) {
+    if (fire & 2)
+    if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, slot, true, 0.5)) {
         M_Mage_Attack_Push();
-        weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready);
+        weapon_thinkf(actor, slot, WFRAME_FIRE2, 0, w_ready);
     }
 }
 
@@ -151,7 +151,7 @@ void M_Mage_Attack_Spike_Explode()
        self.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, other);
+       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);
 
        remove (self);
 }
@@ -297,7 +297,7 @@ void M_Mage_Defend_Heal()
        if(washealed)
        {
                setanim(self, self.anim_shoot, true, true, true);
-               self.attack_finished_single = time + (autocvar_g_monster_mage_heal_delay);
+               self.attack_finished_single[0] = time + (autocvar_g_monster_mage_heal_delay);
                self.anim_finished = time + 1.5;
        }
 }
@@ -305,11 +305,11 @@ void M_Mage_Defend_Heal()
 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, self.enemy);
+       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);
 
        setanim(self, self.anim_shoot, true, true, true);
-       self.attack_finished_single = time + (autocvar_g_monster_mage_attack_push_delay);
+       self.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_push_delay);
 }
 
 void M_Mage_Attack_Teleport()
@@ -334,7 +334,7 @@ void M_Mage_Attack_Teleport()
        self.fixangle = true;
        self.velocity *= 0.5;
 
-       self.attack_finished_single = time + 0.2;
+       self.attack_finished_single[0] = time + 0.2;
 }
 
 void M_Mage_Defend_Shield_Remove()
@@ -350,7 +350,7 @@ void M_Mage_Defend_Shield()
        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 = time + 1;
+       self.attack_finished_single[0] = time + 1;
        self.anim_finished = time + 1;
 }
 
@@ -363,7 +363,7 @@ float M_Mage_Attack(float attack_type, entity targ)
                        if(random() <= 0.7)
                        {
                                Weapon wep = WEP_MAGE_SPIKE;
-                               wep.wr_think(wep, self, false, true);
+                               wep.wr_think(wep, self, 0, 2);
                                return true;
                        }
 
@@ -382,10 +382,10 @@ float M_Mage_Attack(float attack_type, entity targ)
                                else
                                {
                                        setanim(self, self.anim_shoot, true, true, true);
-                                       self.attack_finished_single = time + (autocvar_g_monster_mage_attack_spike_delay);
+                                       self.attack_finished_single[0] = time + (autocvar_g_monster_mage_attack_spike_delay);
                                        self.anim_finished = time + 1;
                                        Weapon wep = WEP_MAGE_SPIKE;
-                                       wep.wr_think(wep, self, true, false);
+                                       wep.wr_think(wep, self, 0, 1);
                                        return true;
                                }
                        }
@@ -421,7 +421,7 @@ spawnfunc(monster_mage) { Monster_Spawn(MON_MAGE.monsterid); }
                        }
 
                        if(self.health < (autocvar_g_monster_mage_heal_minhealth) || need_help)
-                       if(time >= self.attack_finished_single)
+                       if(time >= self.attack_finished_single[0])
                        if(random() < 0.5)
                                M_Mage_Defend_Heal();