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