]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/wyvern.qc
af174603d26b7e273aee653547c4bc2bf2d25755
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / wyvern.qc
1 #ifndef MENUQC
2 bool M_Wyvern(int);
3 #endif
4 REGISTER_MONSTER_SIMPLE(
5 /* MON_##id   */ WYVERN,
6 /* spawnflags */ MONSTER_TYPE_FLY | MONSTER_SIZE_BROKEN | MON_FLAG_RANGED | MON_FLAG_RIDE,
7 /* mins,maxs  */ '-20 -20 -58', '20 20 20',
8 /* model      */ "wizard.mdl",
9 /* netname    */ "wyvern",
10 /* fullname   */ _("Wyvern")
11 ) {
12 #ifndef MENUQC
13         this.monster_func = M_Wyvern;
14         this.monster_func(MR_PRECACHE);
15 #endif
16 }
17
18 #ifdef SVQC
19 float autocvar_g_monster_wyvern_health;
20 float autocvar_g_monster_wyvern_damageforcescale = 0.6;
21 float autocvar_g_monster_wyvern_attack_fireball_damage;
22 float autocvar_g_monster_wyvern_attack_fireball_edgedamage;
23 float autocvar_g_monster_wyvern_attack_fireball_damagetime;
24 float autocvar_g_monster_wyvern_attack_fireball_force;
25 float autocvar_g_monster_wyvern_attack_fireball_radius;
26 float autocvar_g_monster_wyvern_attack_fireball_speed;
27 float autocvar_g_monster_wyvern_speed_stop;
28 float autocvar_g_monster_wyvern_speed_run;
29 float autocvar_g_monster_wyvern_speed_walk;
30
31 /*
32 const float wyvern_anim_hover   = 0;
33 const float wyvern_anim_fly             = 1;
34 const float wyvern_anim_magic   = 2;
35 const float wyvern_anim_pain    = 3;
36 const float wyvern_anim_death   = 4;
37 */
38
39 void M_Wyvern_Attack_Fireball_Explode()
40 {SELFPARAM();
41         entity e;
42         if(self)
43         {
44                 Send_Effect(EFFECT_FIREBALL_EXPLODE, self.origin, '0 0 0', 1);
45
46                 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);
47
48                 for(e = world; (e = findfloat(e, takedamage, DAMAGE_AIM)); ) if(vlen(e.origin - self.origin) <= (autocvar_g_monster_wyvern_attack_fireball_radius))
49                         Fire_AddDamage(e, self, 5 * MONSTER_SKILLMOD(self), (autocvar_g_monster_wyvern_attack_fireball_damagetime), self.projectiledeathtype);
50
51                 remove(self);
52         }
53 }
54
55 void M_Wyvern_Attack_Fireball_Touch()
56 {
57         PROJECTILE_TOUCH;
58
59         M_Wyvern_Attack_Fireball_Explode();
60 }
61
62 void M_Wyvern_Attack_Fireball()
63 {SELFPARAM();
64         entity missile = spawn();
65         vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
66
67         monster_makevectors(self.enemy);
68
69         missile.owner = missile.realowner = self;
70         missile.solid = SOLID_TRIGGER;
71         missile.movetype = MOVETYPE_FLYMISSILE;
72         missile.projectiledeathtype = DEATH_MONSTER_WYVERN;
73         setsize(missile, '-6 -6 -6', '6 6 6');
74         setorigin(missile, self.origin + self.view_ofs + v_forward * 14);
75         missile.flags = FL_PROJECTILE;
76         missile.velocity = dir * (autocvar_g_monster_wyvern_attack_fireball_speed);
77         missile.avelocity = '300 300 300';
78         missile.nextthink = time + 5;
79         missile.think = M_Wyvern_Attack_Fireball_Explode;
80         missile.enemy = self.enemy;
81         missile.touch = M_Wyvern_Attack_Fireball_Touch;
82         CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
83 }
84
85 float M_Wyvern_Attack(float attack_type)
86 {SELFPARAM();
87         switch(attack_type)
88         {
89                 case MONSTER_ATTACK_MELEE:
90                 case MONSTER_ATTACK_RANGED:
91                 {
92                         self.attack_finished_single = time + 1.2;
93                         self.anim_finished = time + 1.2;
94
95                         M_Wyvern_Attack_Fireball();
96
97                         return true;
98                 }
99         }
100
101         return false;
102 }
103
104 void spawnfunc_monster_wyvern() { Monster_Spawn(MON_WYVERN.monsterid); }
105 #endif // SVQC
106
107 bool M_Wyvern(int req)
108 {SELFPARAM();
109         switch(req)
110         {
111                 #ifdef SVQC
112                 case MR_THINK:
113                 {
114                         return true;
115                 }
116                 case MR_PAIN:
117                 {
118                         self.pain_finished = time + 0.5;
119                         setanim(self, self.anim_pain1, true, true, false);
120                         return true;
121                 }
122                 case MR_DEATH:
123                 {
124                         setanim(self, self.anim_die1, false, true, true);
125                         self.velocity_x = -200 + 400 * random();
126                         self.velocity_y = -200 + 400 * random();
127                         self.velocity_z = 100 + 100 * random();
128                         return true;
129                 }
130                 #endif
131                 #ifndef MENUQC
132                 case MR_ANIM:
133                 {
134                         vector none = '0 0 0';
135                         self.anim_die1 = animfixfps(self, '4 1 0.5', none); // 2 seconds
136                         self.anim_walk = animfixfps(self, '1 1 1', none);
137                         self.anim_idle = animfixfps(self, '0 1 1', none);
138                         self.anim_pain1 = animfixfps(self, '3 1 2', none); // 0.5 seconds
139                         self.anim_shoot = animfixfps(self, '2 1 5', none); // analyze models and set framerate
140                         self.anim_run = animfixfps(self, '1 1 1', none);
141
142                         return true;
143                 }
144                 #endif
145                 #ifdef SVQC
146                 case MR_SETUP:
147                 {
148                         if(!self.health) self.health = (autocvar_g_monster_wyvern_health);
149                         if(!self.speed) { self.speed = (autocvar_g_monster_wyvern_speed_walk); }
150                         if(!self.speed2) { self.speed2 = (autocvar_g_monster_wyvern_speed_run); }
151                         if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_wyvern_speed_stop); }
152                         if(!self.damageforcescale) { self.damageforcescale = (autocvar_g_monster_wyvern_damageforcescale); }
153
154                         self.monster_loot = spawnfunc_item_cells;
155                         self.monster_attackfunc = M_Wyvern_Attack;
156
157                         return true;
158                 }
159                 case MR_PRECACHE:
160                 {
161                         return true;
162                 }
163                 #endif
164         }
165
166         return true;
167 }