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