]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/monster/wyvern.qc
Merge branch 'master' into TimePath/deathtypes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / wyvern.qc
index 19f8a53be887f2e410e4f50a7cf58c8e49da7c70..ac9f32205dae432e9104065d29957df55dd7debd 100644 (file)
@@ -18,23 +18,71 @@ ENDCLASS(Wyvern)
 
 REGISTER_MONSTER(WYVERN, NEW(Wyvern)) {
 #ifndef MENUQC
-    MON_ACTION(this, MR_PRECACHE);
+    this.mr_precache(this);
 #endif
 }
 
+#include "../../weapons/all.qh"
+
+CLASS(WyvernAttack, PortoLaunch)
+/* flags     */ ATTRIB(WyvernAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
+/* impulse   */ ATTRIB(WyvernAttack, impulse, int, 9);
+/* refname   */ ATTRIB(WyvernAttack, netname, string, "wyvern");
+/* wepname   */ ATTRIB(WyvernAttack, message, string, _("Wyvern attack"));
+ENDCLASS(WyvernAttack)
+REGISTER_WEAPON(WYVERN_ATTACK, NEW(WyvernAttack));
+
 #endif
 
 #ifdef IMPLEMENTATION
 
 #ifdef SVQC
-float autocvar_g_monster_wyvern_health;
-float autocvar_g_monster_wyvern_damageforcescale = 0.6;
+
 float autocvar_g_monster_wyvern_attack_fireball_damage;
 float autocvar_g_monster_wyvern_attack_fireball_edgedamage;
 float autocvar_g_monster_wyvern_attack_fireball_damagetime;
 float autocvar_g_monster_wyvern_attack_fireball_force;
 float autocvar_g_monster_wyvern_attack_fireball_radius;
 float autocvar_g_monster_wyvern_attack_fireball_speed;
+
+void M_Wyvern_Attack_Fireball_Explode();
+void M_Wyvern_Attack_Fireball_Touch();
+
+METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, bool fire1, bool fire2)) {
+    if (fire1)
+    if (time > actor.attack_finished_single || weapon_prepareattack(thiswep, actor, false, 1.2)) {
+        if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
+               if (IS_MONSTER(actor)) {
+                       actor.attack_finished_single = time + 1.2;
+                       actor.anim_finished = time + 1.2;
+                       monster_makevectors(actor.enemy);
+               }
+
+               entity missile = spawn();
+               missile.owner = missile.realowner = actor;
+               missile.solid = SOLID_TRIGGER;
+               missile.movetype = MOVETYPE_FLYMISSILE;
+               missile.projectiledeathtype = DEATH_MONSTER_WYVERN.m_id;
+               setsize(missile, '-6 -6 -6', '6 6 6');
+               setorigin(missile, actor.origin + actor.view_ofs + v_forward * 14);
+               missile.flags = FL_PROJECTILE;
+               missile.velocity = w_shotdir * (autocvar_g_monster_wyvern_attack_fireball_speed);
+               missile.avelocity = '300 300 300';
+               missile.nextthink = time + 5;
+               missile.think = M_Wyvern_Attack_Fireball_Explode;
+               missile.touch = M_Wyvern_Attack_Fireball_Touch;
+               CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
+
+        weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready);
+    }
+}
+
+METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack thiswep)) {
+       return true;
+}
+
+float autocvar_g_monster_wyvern_health;
+float autocvar_g_monster_wyvern_damageforcescale = 0.6;
 float autocvar_g_monster_wyvern_speed_stop;
 float autocvar_g_monster_wyvern_speed_run;
 float autocvar_g_monster_wyvern_speed_walk;
@@ -48,19 +96,19 @@ const float wyvern_anim_death       = 4;
 */
 
 void M_Wyvern_Attack_Fireball_Explode()
-{SELFPARAM();
-       entity e;
-       if(self)
-       {
-               Send_Effect(EFFECT_FIREBALL_EXPLODE, self.origin, '0 0 0', 1);
+{
+       SELFPARAM();
+       Send_Effect(EFFECT_FIREBALL_EXPLODE, self.origin, '0 0 0', 1);
 
-               RadiusDamage(self, self.realowner, (autocvar_g_monster_wyvern_attack_fireball_damage), (autocvar_g_monster_wyvern_attack_fireball_edgedamage), (autocvar_g_monster_wyvern_attack_fireball_force), world, world, (autocvar_g_monster_wyvern_attack_fireball_radius), self.projectiledeathtype, world);
+       entity owner = self.realowner;
 
-               for(e = world; (e = findfloat(e, takedamage, DAMAGE_AIM)); ) if(vlen(e.origin - self.origin) <= (autocvar_g_monster_wyvern_attack_fireball_radius))
-                       Fire_AddDamage(e, self, 5 * MONSTER_SKILLMOD(self), (autocvar_g_monster_wyvern_attack_fireball_damagetime), self.projectiledeathtype);
+       RadiusDamage(self, owner, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force, world, world, autocvar_g_monster_wyvern_attack_fireball_radius, self.projectiledeathtype, world);
 
-               remove(self);
-       }
+       for (entity e = world; (e = findfloat(e, takedamage, DAMAGE_AIM)); )
+       if (vlen(e.origin - self.origin) <= (autocvar_g_monster_wyvern_attack_fireball_radius))
+               Fire_AddDamage(e, owner, 5 * MONSTER_SKILLMOD(owner), (autocvar_g_monster_wyvern_attack_fireball_damagetime), self.projectiledeathtype);
+
+       remove(self);
 }
 
 void M_Wyvern_Attack_Fireball_Touch()
@@ -70,41 +118,17 @@ void M_Wyvern_Attack_Fireball_Touch()
        M_Wyvern_Attack_Fireball_Explode();
 }
 
-void M_Wyvern_Attack_Fireball()
-{SELFPARAM();
-       entity missile = spawn();
-       vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
-
-       monster_makevectors(self.enemy);
-
-       missile.owner = missile.realowner = self;
-       missile.solid = SOLID_TRIGGER;
-       missile.movetype = MOVETYPE_FLYMISSILE;
-       missile.projectiledeathtype = DEATH_MONSTER_WYVERN;
-       setsize(missile, '-6 -6 -6', '6 6 6');
-       setorigin(missile, self.origin + self.view_ofs + v_forward * 14);
-       missile.flags = FL_PROJECTILE;
-       missile.velocity = dir * (autocvar_g_monster_wyvern_attack_fireball_speed);
-       missile.avelocity = '300 300 300';
-       missile.nextthink = time + 5;
-       missile.think = M_Wyvern_Attack_Fireball_Explode;
-       missile.enemy = self.enemy;
-       missile.touch = M_Wyvern_Attack_Fireball_Touch;
-       CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
-}
-
-float M_Wyvern_Attack(float attack_type)
-{SELFPARAM();
+float M_Wyvern_Attack(float attack_type, entity targ)
+{
+       SELFPARAM();
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
                case MONSTER_ATTACK_RANGED:
                {
-                       self.attack_finished_single = time + 1.2;
-                       self.anim_finished = time + 1.2;
-
-                       M_Wyvern_Attack_Fireball();
-
+                       w_shotdir = normalize((self.enemy.origin + '0 0 10') - self.origin);
+                       Weapon wep = WEP_WYVERN_ATTACK;
+                       wep.wr_think(wep, self, true, false);
                        return true;
                }
        }
@@ -112,7 +136,7 @@ float M_Wyvern_Attack(float attack_type)
        return false;
 }
 
-void spawnfunc_monster_wyvern() { Monster_Spawn(MON_WYVERN.monsterid); }
+spawnfunc(monster_wyvern) { Monster_Spawn(MON_WYVERN.monsterid); }
 #endif // SVQC
 
                #ifdef SVQC
@@ -153,6 +177,7 @@ void spawnfunc_monster_wyvern() { Monster_Spawn(MON_WYVERN.monsterid); }
                }
                #endif
                #ifdef SVQC
+               spawnfunc(item_cells);
                METHOD(Wyvern, mr_setup, bool(Wyvern thismon))
                {
                        SELFPARAM();