]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/wyvern.qc
a0e670507013ceddb3713db56d4038fad824aaac
[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, M_Model("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     this.mr_precache(this);
22 #endif
23 }
24
25 #include <common/weapons/all.qh>
26
27 CLASS(WyvernAttack, PortoLaunch)
28 /* flags     */ ATTRIB(WyvernAttack, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED);
29 /* impulse   */ ATTRIB(WyvernAttack, impulse, int, 9);
30 /* refname   */ ATTRIB(WyvernAttack, netname, string, "wyvern");
31 /* wepname   */ ATTRIB(WyvernAttack, m_name, string, _("Wyvern attack"));
32 ENDCLASS(WyvernAttack)
33 REGISTER_WEAPON(WYVERN_ATTACK, NEW(WyvernAttack));
34
35 #endif
36
37 #ifdef IMPLEMENTATION
38
39 #ifdef SVQC
40
41 float autocvar_g_monster_wyvern_attack_fireball_damage;
42 float autocvar_g_monster_wyvern_attack_fireball_edgedamage;
43 float autocvar_g_monster_wyvern_attack_fireball_damagetime;
44 float autocvar_g_monster_wyvern_attack_fireball_force;
45 float autocvar_g_monster_wyvern_attack_fireball_radius;
46 float autocvar_g_monster_wyvern_attack_fireball_speed;
47
48 void M_Wyvern_Attack_Fireball_Explode(entity this);
49 void M_Wyvern_Attack_Fireball_Touch(entity this);
50
51 SOUND(WyvernAttack_FIRE, W_Sound("electro_fire"));
52 METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire))
53 {
54     TC(WyvernAttack, thiswep);
55     if (fire & 1)
56     if (time > actor.attack_finished_single[0] || weapon_prepareattack(thiswep, actor, weaponentity, false, 1.2)) {
57         if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, v_forward, false, 0, SND_WyvernAttack_FIRE, CH_WEAPON_B, 0);
58                 if (IS_MONSTER(actor)) {
59                         actor.attack_finished_single[0] = time + 1.2;
60                         actor.anim_finished = time + 1.2;
61                         monster_makevectors(actor, actor.enemy);
62                 }
63
64                 entity missile = spawn();
65                 missile.owner = missile.realowner = actor;
66                 missile.solid = SOLID_TRIGGER;
67                 missile.movetype = MOVETYPE_FLYMISSILE;
68                 missile.projectiledeathtype = DEATH_MONSTER_WYVERN.m_id;
69                 setsize(missile, '-6 -6 -6', '6 6 6');
70                 setorigin(missile, actor.origin + actor.view_ofs + v_forward * 14);
71                 missile.flags = FL_PROJECTILE;
72                 missile.velocity = w_shotdir * (autocvar_g_monster_wyvern_attack_fireball_speed);
73                 missile.avelocity = '300 300 300';
74                 missile.nextthink = time + 5;
75                 setthink(missile, M_Wyvern_Attack_Fireball_Explode);
76                 settouch(missile, M_Wyvern_Attack_Fireball_Touch);
77                 CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
78
79         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
80     }
81 }
82
83 METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor)) {
84     TC(WyvernAttack, this);
85         return true;
86 }
87
88 float autocvar_g_monster_wyvern_health;
89 float autocvar_g_monster_wyvern_damageforcescale = 0.6;
90 float autocvar_g_monster_wyvern_speed_stop;
91 float autocvar_g_monster_wyvern_speed_run;
92 float autocvar_g_monster_wyvern_speed_walk;
93
94 /*
95 const float wyvern_anim_hover   = 0;
96 const float wyvern_anim_fly             = 1;
97 const float wyvern_anim_magic   = 2;
98 const float wyvern_anim_pain    = 3;
99 const float wyvern_anim_death   = 4;
100 */
101
102 void M_Wyvern_Attack_Fireball_Explode(entity this)
103 {
104         Send_Effect(EFFECT_FIREBALL_EXPLODE, this.origin, '0 0 0', 1);
105
106         entity own = this.realowner;
107
108         RadiusDamage(this, own, 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, this.projectiledeathtype, world);
109
110         FOREACH_ENTITY_FLOAT(takedamage, DAMAGE_AIM,
111         {
112                 if(vdist(it.origin - this.origin, <=, autocvar_g_monster_wyvern_attack_fireball_radius))
113                         Fire_AddDamage(it, own, 5 * MONSTER_SKILLMOD(own), autocvar_g_monster_wyvern_attack_fireball_damagetime, this.projectiledeathtype);
114         });
115
116         remove(this);
117 }
118
119 void M_Wyvern_Attack_Fireball_Touch(entity this)
120 {
121         PROJECTILE_TOUCH;
122
123         M_Wyvern_Attack_Fireball_Explode(this);
124 }
125
126 bool M_Wyvern_Attack(int attack_type, entity actor, entity targ)
127 {
128         .entity weaponentity = weaponentities[0];
129         switch(attack_type)
130         {
131                 case MONSTER_ATTACK_MELEE:
132                 case MONSTER_ATTACK_RANGED:
133                 {
134                         w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
135                         Weapon wep = WEP_WYVERN_ATTACK;
136                         wep.wr_think(wep, actor, weaponentity, 1);
137                         return true;
138                 }
139         }
140
141         return false;
142 }
143
144 spawnfunc(monster_wyvern) { Monster_Spawn(this, MON_WYVERN.monsterid); }
145 #endif // SVQC
146
147 #ifdef SVQC
148 METHOD(Wyvern, mr_think, bool(Wyvern this, entity actor))
149 {
150     TC(Wyvern, this);
151     return true;
152 }
153
154 METHOD(Wyvern, mr_pain, bool(Wyvern this, entity actor))
155 {
156     TC(Wyvern, this);
157     actor.pain_finished = time + 0.5;
158     setanim(actor, actor.anim_pain1, true, true, false);
159     return true;
160 }
161
162 METHOD(Wyvern, mr_death, bool(Wyvern this, entity actor))
163 {
164     TC(Wyvern, this);
165     setanim(actor, actor.anim_die1, false, true, true);
166     actor.velocity_x = -200 + 400 * random();
167     actor.velocity_y = -200 + 400 * random();
168     actor.velocity_z = 100 + 100 * random();
169     return true;
170 }
171 #endif
172 #ifndef MENUQC
173 METHOD(Wyvern, mr_anim, bool(Wyvern this, entity actor))
174 {
175     TC(Wyvern, this);
176     vector none = '0 0 0';
177     actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds
178     actor.anim_walk = animfixfps(actor, '1 1 1', none);
179     actor.anim_idle = animfixfps(actor, '0 1 1', none);
180     actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
181     actor.anim_shoot = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
182     actor.anim_run = animfixfps(actor, '1 1 1', none);
183     return true;
184 }
185 #endif
186 #ifdef SVQC
187 spawnfunc(item_cells);
188 METHOD(Wyvern, mr_setup, bool(Wyvern this, entity actor))
189 {
190     TC(Wyvern, this);
191     if(!actor.health) actor.health = (autocvar_g_monster_wyvern_health);
192     if(!actor.speed) { actor.speed = (autocvar_g_monster_wyvern_speed_walk); }
193     if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_wyvern_speed_run); }
194     if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_wyvern_speed_stop); }
195     if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_wyvern_damageforcescale); }
196
197     actor.monster_loot = spawnfunc_item_cells;
198     actor.monster_attackfunc = M_Wyvern_Attack;
199
200     return true;
201 }
202
203 METHOD(Wyvern, mr_precache, bool(Wyvern this))
204 {
205     TC(Wyvern, this);
206     return true;
207 }
208 #endif
209
210 #endif