]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/wyvern.qc
Merge branch 'master' into Mario/nade_drop
[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         self.monster_spawnfunc = spawnfunc_monster_wyvern;
100
101         if(Monster_CheckAppearFlags(self))
102                 return;
103
104         if(!monster_initialize(MON_WYVERN, TRUE)) { remove(self); return; }
105 }
106
107 // compatibility with old spawns
108 void spawnfunc_monster_wizard() { spawnfunc_monster_wyvern(); }
109
110 float m_wyvern(float req)
111 {
112         switch(req)
113         {
114                 case MR_THINK:
115                 {
116                         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);
117                         return TRUE;
118                 }
119                 case MR_DEATH:
120                 {
121                         self.frame = wyvern_anim_death;
122                         self.velocity_x = -200 + 400 * random();
123                         self.velocity_y = -200 + 400 * random();
124                         self.velocity_z = 100 + 100 * random();
125                         return TRUE;
126                 }
127                 case MR_SETUP:
128                 {
129                         if(!self.health) self.health = (autocvar_g_monster_wyvern_health);
130
131                         self.monster_loot = spawnfunc_item_cells;
132                         self.monster_attackfunc = wyvern_attack;
133                         self.frame = wyvern_anim_hover;
134
135                         return TRUE;
136                 }
137                 case MR_PRECACHE:
138                 {
139                         precache_model ("models/monsters/wizard.mdl");
140                         return TRUE;
141                 }
142         }
143
144         return TRUE;
145 }
146
147 #endif // SVQC
148 #ifdef CSQC
149 float m_wyvern(float req)
150 {
151         switch(req)
152         {
153                 case MR_PRECACHE:
154                 {
155                         precache_model ("models/monsters/wizard.mdl");
156                         return TRUE;
157                 }
158         }
159
160         return TRUE;
161 }
162
163 #endif // CSQC
164 #endif // REGISTER_MONSTER