]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/monsters/monster/wyvern.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / wyvern.qc
1 // size
2 const vector WYVERN_MIN = '-20 -20 -58';
3 const vector WYVERN_MAX = '20 20 20';
4
5 // model
6 string WYVERN_MODEL = "models/monsters/wizard.mdl";
7
8 #ifdef SVQC
9 // cvars
10 float autocvar_g_monster_wyvern;
11 float autocvar_g_monster_wyvern_health;
12 float autocvar_g_monster_wyvern_speed_walk;
13 float autocvar_g_monster_wyvern_speed_run;
14 float autocvar_g_monster_wyvern_fireball_damage;
15 float autocvar_g_monster_wyvern_fireball_force;
16 float autocvar_g_monster_wyvern_fireball_radius;
17 float autocvar_g_monster_wyvern_fireball_edgedamage;
18 float autocvar_g_monster_wyvern_fireball_damagetime;
19 float autocvar_g_monster_wyvern_fireball_speed;
20
21 // animations
22 const float wyvern_anim_hover   = 0;
23 const float wyvern_anim_fly     = 1;
24 const float wyvern_anim_magic   = 2;
25 const float wyvern_anim_pain    = 3;
26 const float wyvern_anim_death   = 4;
27
28 void wyvern_think ()
29 {
30         self.think = wyvern_think;
31         self.nextthink = time + self.ticrate;
32         
33         monster_move(autocvar_g_monster_wyvern_speed_run, autocvar_g_monster_wyvern_speed_walk, 300, wyvern_anim_fly, wyvern_anim_hover, wyvern_anim_hover);
34 }
35
36 void wyvern_fireball_explode()
37 {
38         entity e;
39         if(self)
40         {
41                 pointparticles(particleeffectnum("fireball_explode"), self.origin, '0 0 0', 1);
42                 
43                 RadiusDamage(self, self.realowner, autocvar_g_monster_wyvern_fireball_damage, autocvar_g_monster_wyvern_fireball_edgedamage, autocvar_g_monster_wyvern_fireball_force, world, autocvar_g_monster_wyvern_fireball_radius, self.projectiledeathtype, world);
44                 
45                 for(e = world; (e = findfloat(e, takedamage, DAMAGE_AIM)); ) if(vlen(e.origin - self.origin) <= autocvar_g_monster_wyvern_fireball_radius)
46                         Fire_AddDamage(e, self, 5 * monster_skill, autocvar_g_monster_wyvern_fireball_damagetime, self.projectiledeathtype);
47                 
48                 remove(self);
49         }
50 }
51
52 void wyvern_fireball_touch()
53 {
54         PROJECTILE_TOUCH;
55         
56         wyvern_fireball_explode();
57 }
58
59 void wyvern_fireball()
60 {
61         entity missile = spawn();
62         vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
63         
64         monster_makevectors(self.enemy);
65
66         missile.owner = missile.realowner = self;
67         missile.solid = SOLID_TRIGGER;
68         missile.movetype = MOVETYPE_FLYMISSILE;
69         missile.projectiledeathtype = DEATH_MONSTER_WYVERN;
70         setsize(missile, '-6 -6 -6', '6 6 6');          
71         setorigin(missile, self.origin + self.view_ofs + v_forward * 14);
72         missile.flags = FL_PROJECTILE;
73         missile.velocity = dir * autocvar_g_monster_wyvern_fireball_speed;
74         missile.avelocity = '300 300 300';
75         missile.nextthink = time + 5;
76         missile.think = wyvern_fireball_explode;
77         missile.enemy = self.enemy;
78         missile.touch = wyvern_fireball_touch;
79         CSQCProjectile(missile, TRUE, PROJECTILE_FIREMINE, TRUE);
80 }
81
82 float wyvern_attack(float attack_type)
83 {
84         switch(attack_type)
85         {
86                 case MONSTER_ATTACK_MELEE:
87                 case MONSTER_ATTACK_RANGED:
88                 {
89                         self.attack_finished_single = time + 1.2;
90                         
91                         wyvern_fireball();
92                         
93                         return TRUE;
94                 }
95         }
96         
97         return FALSE;
98 }
99
100 void wyvern_die()
101 {
102         Monster_CheckDropCvars ("wyvern");
103         
104         self.think                      = monster_dead_think;
105         self.nextthink          = time + self.ticrate;
106         self.ltime                      = time + 5;
107         self.velocity_x         = -200 + 400 * random();
108         self.velocity_y         = -200 + 400 * random();
109         self.velocity_z         = 100 + 100 * random();
110         
111         monsters_setframe(wyvern_anim_death);
112         
113         monster_hook_death(); // for post-death mods
114 }
115
116 void wyvern_spawn()
117 {
118         if not(self.health)
119                 self.health = autocvar_g_monster_wyvern_health;
120         
121         self.classname                  = "monster_wyvern";
122         self.monster_attackfunc = wyvern_attack;
123         self.nextthink                  = time + random() * 0.5 + 0.1;
124         self.movetype                   = MOVETYPE_FLY;
125         self.flags                         |= FL_FLY;
126         self.think                              = wyvern_think;
127         
128         monster_setupsounds("wyvern");
129         
130         monster_hook_spawn(); // for post-spawn mods
131 }
132
133 void spawnfunc_monster_wyvern()
134 {       
135         if not(autocvar_g_monster_wyvern) { remove(self); return; }
136         
137         self.monster_spawnfunc = spawnfunc_monster_wyvern;
138         
139         if(Monster_CheckAppearFlags(self))
140                 return;
141         
142         self.scale = 1.3;
143         
144         if not (monster_initialize(
145                          "Wyvern", MONSTER_WYVERN,
146                          WYVERN_MIN, WYVERN_MAX,
147                          TRUE,
148                          wyvern_die, wyvern_spawn))
149         {
150                 remove(self);
151                 return;
152         }
153 }
154
155 // compatibility with old spawns
156 void spawnfunc_monster_wizard() { spawnfunc_monster_wyvern(); }
157
158 #endif // SVQC