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