]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/monsters/monster/wyvern.qc
Intrusify sandbox objects and remove some dead code
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / monster / wyvern.qc
1 #include "wyvern.qh"
2
3 #ifdef IMPLEMENTATION
4
5 #ifdef SVQC
6
7 float autocvar_g_monster_wyvern_attack_fireball_damage;
8 float autocvar_g_monster_wyvern_attack_fireball_edgedamage;
9 float autocvar_g_monster_wyvern_attack_fireball_damagetime;
10 float autocvar_g_monster_wyvern_attack_fireball_force;
11 float autocvar_g_monster_wyvern_attack_fireball_radius;
12 float autocvar_g_monster_wyvern_attack_fireball_speed;
13
14 void M_Wyvern_Attack_Fireball_Explode(entity this);
15 void M_Wyvern_Attack_Fireball_Touch(entity this, entity toucher);
16
17 SOUND(WyvernAttack_FIRE, W_Sound("electro_fire"));
18 METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire))
19 {
20     TC(WyvernAttack, thiswep);
21     if (fire & 1)
22     if (time > actor.attack_finished_single[0] || weapon_prepareattack(thiswep, actor, weaponentity, false, 1.2)) {
23         if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_WyvernAttack_FIRE, CH_WEAPON_B, 0);
24                 if (IS_MONSTER(actor)) {
25                         actor.attack_finished_single[0] = time + 1.2;
26                         actor.anim_finished = time + 1.2;
27                         monster_makevectors(actor, actor.enemy);
28                 }
29
30                 entity missile = spawn();
31                 missile.owner = missile.realowner = actor;
32                 missile.solid = SOLID_TRIGGER;
33                 set_movetype(missile, MOVETYPE_FLYMISSILE);
34                 missile.projectiledeathtype = DEATH_MONSTER_WYVERN.m_id;
35                 setsize(missile, '-6 -6 -6', '6 6 6');
36                 setorigin(missile, actor.origin + actor.view_ofs + v_forward * 14);
37                 missile.flags = FL_PROJECTILE;
38         IL_PUSH(g_projectiles, missile);
39                 missile.velocity = w_shotdir * (autocvar_g_monster_wyvern_attack_fireball_speed);
40                 missile.avelocity = '300 300 300';
41                 missile.nextthink = time + 5;
42                 setthink(missile, M_Wyvern_Attack_Fireball_Explode);
43                 settouch(missile, M_Wyvern_Attack_Fireball_Touch);
44                 CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
45
46         weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
47     }
48 }
49
50 METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor)) {
51     TC(WyvernAttack, this);
52         return true;
53 }
54
55 float autocvar_g_monster_wyvern_health;
56 float autocvar_g_monster_wyvern_damageforcescale = 0.6;
57 float autocvar_g_monster_wyvern_speed_stop;
58 float autocvar_g_monster_wyvern_speed_run;
59 float autocvar_g_monster_wyvern_speed_walk;
60
61 /*
62 const float wyvern_anim_hover   = 0;
63 const float wyvern_anim_fly             = 1;
64 const float wyvern_anim_magic   = 2;
65 const float wyvern_anim_pain    = 3;
66 const float wyvern_anim_death   = 4;
67 */
68
69 void M_Wyvern_Attack_Fireball_Explode(entity this)
70 {
71         Send_Effect(EFFECT_FIREBALL_EXPLODE, this.origin, '0 0 0', 1);
72
73         entity own = this.realowner;
74
75         RadiusDamage(this, own, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force, NULL, NULL, autocvar_g_monster_wyvern_attack_fireball_radius, this.projectiledeathtype, NULL);
76
77         FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_monster_wyvern_attack_fireball_radius, it.takedamage == DAMAGE_AIM,
78         {
79                 Fire_AddDamage(it, own, 5 * MONSTER_SKILLMOD(own), autocvar_g_monster_wyvern_attack_fireball_damagetime, this.projectiledeathtype);
80         });
81
82         delete(this);
83 }
84
85 void M_Wyvern_Attack_Fireball_Touch(entity this, entity toucher)
86 {
87         PROJECTILE_TOUCH(this, toucher);
88
89         M_Wyvern_Attack_Fireball_Explode(this);
90 }
91
92 bool M_Wyvern_Attack(int attack_type, entity actor, entity targ)
93 {
94         .entity weaponentity = weaponentities[0];
95         switch(attack_type)
96         {
97                 case MONSTER_ATTACK_MELEE:
98                 case MONSTER_ATTACK_RANGED:
99                 {
100                         w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
101                         Weapon wep = WEP_WYVERN_ATTACK;
102                         wep.wr_think(wep, actor, weaponentity, 1);
103                         return true;
104                 }
105         }
106
107         return false;
108 }
109
110 spawnfunc(monster_wyvern) { Monster_Spawn(this, MON_WYVERN.monsterid); }
111 #endif // SVQC
112
113 #ifdef SVQC
114 METHOD(Wyvern, mr_think, bool(Wyvern this, entity actor))
115 {
116     TC(Wyvern, this);
117     return true;
118 }
119
120 METHOD(Wyvern, mr_pain, float(Wyvern this, entity actor, float damage_take, entity attacker, float deathtype))
121 {
122     TC(Wyvern, this);
123     actor.pain_finished = time + 0.5;
124     setanim(actor, actor.anim_pain1, true, true, false);
125     return damage_take;
126 }
127
128 METHOD(Wyvern, mr_death, bool(Wyvern this, entity actor))
129 {
130     TC(Wyvern, this);
131     setanim(actor, actor.anim_die1, false, true, true);
132     actor.velocity_x = -200 + 400 * random();
133     actor.velocity_y = -200 + 400 * random();
134     actor.velocity_z = 100 + 100 * random();
135     return true;
136 }
137 #endif
138 #ifdef GAMEQC
139 METHOD(Wyvern, mr_anim, bool(Wyvern this, entity actor))
140 {
141     TC(Wyvern, this);
142     vector none = '0 0 0';
143     actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds
144     actor.anim_walk = animfixfps(actor, '1 1 1', none);
145     actor.anim_idle = animfixfps(actor, '0 1 1', none);
146     actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
147     actor.anim_shoot = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
148     actor.anim_run = animfixfps(actor, '1 1 1', none);
149     return true;
150 }
151 #endif
152 #ifdef SVQC
153 spawnfunc(item_cells);
154 METHOD(Wyvern, mr_setup, bool(Wyvern this, entity actor))
155 {
156     TC(Wyvern, this);
157     if(!actor.health) actor.health = (autocvar_g_monster_wyvern_health);
158     if(!actor.speed) { actor.speed = (autocvar_g_monster_wyvern_speed_walk); }
159     if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_wyvern_speed_run); }
160     if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_wyvern_speed_stop); }
161     if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_wyvern_damageforcescale); }
162
163     actor.monster_loot = spawnfunc_item_cells;
164     actor.monster_attackfunc = M_Wyvern_Attack;
165
166     return true;
167 }
168
169 METHOD(Wyvern, mr_precache, bool(Wyvern this))
170 {
171     TC(Wyvern, this);
172     return true;
173 }
174 #endif
175
176 #endif