]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/wyvern.qc
26dbb186c07a0dd00a826ac76779bce73c27c039
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / wyvern.qc
1 #ifdef REGISTER_MONSTER
2 REGISTER_MONSTER(
3 /* MON_##id   */ WYVERN,
4 /* function   */ m_wyvern,
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_attack_fireball_damage;
16 float autocvar_g_monster_wyvern_attack_fireball_edgedamage;
17 float autocvar_g_monster_wyvern_attack_fireball_damagetime;
18 float autocvar_g_monster_wyvern_attack_fireball_force;
19 float autocvar_g_monster_wyvern_attack_fireball_radius;
20 float autocvar_g_monster_wyvern_attack_fireball_speed;
21 float autocvar_g_monster_wyvern_speed_stop;
22 float autocvar_g_monster_wyvern_speed_run;
23 float autocvar_g_monster_wyvern_speed_walk;
24
25 const float wyvern_anim_hover   = 0;
26 const float wyvern_anim_fly             = 1;
27 const float wyvern_anim_magic   = 2;
28 const float wyvern_anim_pain    = 3;
29 const float wyvern_anim_death   = 4;
30
31 void wyvern_fireball_explode()
32 {
33         entity e;
34         if(self)
35         {
36                 pointparticles(particleeffectnum("fireball_explode"), self.origin, '0 0 0', 1);
37
38                 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, (autocvar_g_monster_wyvern_attack_fireball_radius), self.projectiledeathtype, world);
39
40                 for(e = world; (e = findfloat(e, takedamage, DAMAGE_AIM)); ) if(vlen(e.origin - self.origin) <= (autocvar_g_monster_wyvern_attack_fireball_radius))
41                         Fire_AddDamage(e, self, 5 * Monster_SkillModifier(), (autocvar_g_monster_wyvern_attack_fireball_damagetime), self.projectiledeathtype);
42
43                 remove(self);
44         }
45 }
46
47 void wyvern_fireball_touch()
48 {
49         PROJECTILE_TOUCH;
50
51         wyvern_fireball_explode();
52 }
53
54 void wyvern_fireball()
55 {
56         entity missile = spawn();
57         vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
58
59         monster_makevectors(self.enemy);
60
61         missile.owner = missile.realowner = self;
62         missile.solid = SOLID_TRIGGER;
63         missile.movetype = MOVETYPE_FLYMISSILE;
64         missile.projectiledeathtype = DEATH_MONSTER_WYVERN;
65         setsize(missile, '-6 -6 -6', '6 6 6');
66         setorigin(missile, self.origin + self.view_ofs + v_forward * 14);
67         missile.flags = FL_PROJECTILE;
68         missile.velocity = dir * (autocvar_g_monster_wyvern_attack_fireball_speed);
69         missile.avelocity = '300 300 300';
70         missile.nextthink = time + 5;
71         missile.think = wyvern_fireball_explode;
72         missile.enemy = self.enemy;
73         missile.touch = wyvern_fireball_touch;
74         CSQCProjectile(missile, TRUE, PROJECTILE_FIREMINE, TRUE);
75 }
76
77 float wyvern_attack(float attack_type)
78 {
79         switch(attack_type)
80         {
81                 case MONSTER_ATTACK_MELEE:
82                 case MONSTER_ATTACK_RANGED:
83                 {
84                         self.attack_finished_single = time + 1.2;
85
86                         wyvern_fireball();
87
88                         return TRUE;
89                 }
90         }
91
92         return FALSE;
93 }
94
95 void spawnfunc_monster_wyvern()
96 {
97         self.classname = "monster_wyvern";
98
99         if(Monster_CheckAppearFlags(self, MON_WYVERN))
100                 return;
101
102         if(!monster_initialize(MON_WYVERN)) { remove(self); return; }
103 }
104
105 // compatibility with old spawns
106 void spawnfunc_monster_wizard() { spawnfunc_monster_wyvern(); }
107
108 float m_wyvern(float req)
109 {
110         switch(req)
111         {
112                 case MR_THINK:
113                 {
114                         monster_move((autocvar_g_monster_wyvern_speed_run), (autocvar_g_monster_wyvern_speed_walk), (autocvar_g_monster_wyvern_speed_stop), wyvern_anim_fly, wyvern_anim_hover, wyvern_anim_hover);
115                         return TRUE;
116                 }
117                 case MR_DEATH:
118                 {
119                         self.frame = wyvern_anim_death;
120                         self.velocity_x = -200 + 400 * random();
121                         self.velocity_y = -200 + 400 * random();
122                         self.velocity_z = 100 + 100 * random();
123                         return TRUE;
124                 }
125                 case MR_SETUP:
126                 {
127                         if(!self.health) self.health = (autocvar_g_monster_wyvern_health);
128
129                         self.monster_loot = spawnfunc_item_cells;
130                         self.monster_attackfunc = wyvern_attack;
131                         self.frame = wyvern_anim_hover;
132
133                         return TRUE;
134                 }
135                 case MR_PRECACHE:
136                 {
137                         precache_model ("models/monsters/wizard.mdl");
138                         return TRUE;
139                 }
140         }
141
142         return TRUE;
143 }
144
145 #endif // SVQC
146 #ifdef CSQC
147 float m_wyvern(float req)
148 {
149         switch(req)
150         {
151                 case MR_PRECACHE:
152                 {
153                         precache_model ("models/monsters/wizard.mdl");
154                         return TRUE;
155                 }
156         }
157
158         return TRUE;
159 }
160
161 #endif // CSQC
162 #endif // REGISTER_MONSTER