Xonotic
wyvern.qc
Go to the documentation of this file.
1 #include "wyvern.qh"
2 
3 #ifdef SVQC
4 
5 float autocvar_g_monster_wyvern_attack_fireball_damage;
6 float autocvar_g_monster_wyvern_attack_fireball_edgedamage;
7 float autocvar_g_monster_wyvern_attack_fireball_damagetime;
8 float autocvar_g_monster_wyvern_attack_fireball_force;
9 float autocvar_g_monster_wyvern_attack_fireball_radius;
10 float autocvar_g_monster_wyvern_attack_fireball_speed;
11 
12 void M_Wyvern_Attack_Fireball_Explode(entity this);
13 void M_Wyvern_Attack_Fireball_Touch(entity this, entity toucher);
14 
15 SOUND(WyvernAttack_FIRE, W_Sound("electro_fire"));
16 METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire))
17 {
18  TC(WyvernAttack, thiswep);
19  if (fire & 1)
20  if (time > actor.attack_finished_single[0] || weapon_prepareattack(thiswep, actor, weaponentity, false, 1.2)) {
21  monster_makevectors(actor, actor.enemy);
22  if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_WyvernAttack_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_WYVERN.m_id);
23  if (IS_MONSTER(actor)) {
24  actor.attack_finished_single[0] = time + 1.2;
25  actor.anim_finished = time + 1.2;
26  }
27 
28  entity missile = new(WyvernAttack);
29  missile.owner = missile.realowner = actor;
30  missile.solid = SOLID_TRIGGER;
32  missile.projectiledeathtype = DEATH_MONSTER_WYVERN.m_id;
33  setsize(missile, '-6 -6 -6', '6 6 6');
34  setorigin(missile, actor.origin + actor.view_ofs + v_forward * 14);
35  missile.flags = FL_PROJECTILE;
36  IL_PUSH(g_projectiles, missile);
37  IL_PUSH(g_bot_dodge, missile);
38  missile.velocity = w_shotdir * (autocvar_g_monster_wyvern_attack_fireball_speed);
39  missile.avelocity = '300 300 300';
40  missile.nextthink = time + 5;
41  setthink(missile, M_Wyvern_Attack_Fireball_Explode);
42  settouch(missile, M_Wyvern_Attack_Fireball_Touch);
43  CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
44 
45  weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
46  }
47 }
48 
49 METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor, .entity weaponentity)) {
50  TC(WyvernAttack, this);
51  return true;
52 }
53 
54 float autocvar_g_monster_wyvern_health;
55 float autocvar_g_monster_wyvern_damageforcescale = 0.6;
56 float autocvar_g_monster_wyvern_speed_stop;
57 float autocvar_g_monster_wyvern_speed_run;
58 float autocvar_g_monster_wyvern_speed_walk;
59 
60 /*
61 const float wyvern_anim_hover = 0;
62 const float wyvern_anim_fly = 1;
63 const float wyvern_anim_magic = 2;
64 const float wyvern_anim_pain = 3;
65 const float wyvern_anim_death = 4;
66 */
67 
68 void M_Wyvern_Attack_Fireball_Explode(entity this)
69 {
70  Send_Effect(EFFECT_FIREBALL_EXPLODE, this.origin, '0 0 0', 1);
71 
72  entity own = this.realowner;
73 
74  RadiusDamage(this, own, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force,
75  NULL, NULL, autocvar_g_monster_wyvern_attack_fireball_radius, this.projectiledeathtype, DMG_NOWEP, 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, .entity weaponentity)
93 {
94  switch(attack_type)
95  {
98  {
99  w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin);
100  Weapon wep = WEP_WYVERN_ATTACK;
101  wep.wr_think(wep, actor, weaponentity, 1);
102  return true;
103  }
104  }
105 
106  return false;
107 }
108 
109 spawnfunc(monster_wyvern) { Monster_Spawn(this, true, MON_WYVERN); }
110 #endif // SVQC
111 
112 #ifdef SVQC
113 METHOD(Wyvern, mr_think, bool(Wyvern this, entity actor))
114 {
115  TC(Wyvern, this);
116  return true;
117 }
118 
119 METHOD(Wyvern, mr_pain, float(Wyvern this, entity actor, float damage_take, entity attacker, float deathtype))
120 {
121  TC(Wyvern, this);
122  actor.pain_finished = time + 0.5;
123  setanim(actor, actor.anim_pain1, true, true, false);
124  return damage_take;
125 }
126 
127 METHOD(Wyvern, mr_death, bool(Wyvern this, entity actor))
128 {
129  TC(Wyvern, this);
130  setanim(actor, actor.anim_die1, false, true, true);
131  actor.velocity_x = -200 + 400 * random();
132  actor.velocity_y = -200 + 400 * random();
133  actor.velocity_z = 100 + 100 * random();
134  return true;
135 }
136 #endif
137 #ifdef GAMEQC
138 METHOD(Wyvern, mr_anim, bool(Wyvern this, entity actor))
139 {
140  TC(Wyvern, this);
141  vector none = '0 0 0';
142  actor.anim_die1 = animfixfps(actor, '4 1 0.5', none); // 2 seconds
143  actor.anim_walk = animfixfps(actor, '1 1 1', none);
144  actor.anim_idle = animfixfps(actor, '0 1 1', none);
145  actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
146  actor.anim_shoot = animfixfps(actor, '2 1 5', none); // analyze models and set framerate
147  actor.anim_run = animfixfps(actor, '1 1 1', none);
148  return true;
149 }
150 #endif
151 #ifdef SVQC
152 METHOD(Wyvern, mr_setup, bool(Wyvern this, entity actor))
153 {
154  TC(Wyvern, this);
155  if(!GetResource(this, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_wyvern_health);
156  if(!actor.speed) { actor.speed = (autocvar_g_monster_wyvern_speed_walk); }
157  if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_wyvern_speed_run); }
158  if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_wyvern_speed_stop); }
159  if(!actor.damageforcescale) { actor.damageforcescale = (autocvar_g_monster_wyvern_damageforcescale); }
160 
161  actor.monster_loot = ITEM_Cells;
162  actor.monster_attackfunc = M_Wyvern_Attack;
163 
164  return true;
165 }
166 #endif
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
#define setanim(...)
Definition: anim.qh:45
entity() spawn
float DAMAGE_AIM
Definition: progsdefs.qc:284
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
#define IS_MONSTER(v)
Definition: utils.qh:21
vector w_shotdir
Definition: tracing.qh:19
spawnfunc(info_player_attacker)
Definition: sv_assault.qc:283
origin
Definition: ent_cs.qc:114
string W_Sound(string w_snd)
Definition: all.qc:281
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
#define DMG_NOWEP
Definition: damage.qh:126
IntrusiveList g_bot_dodge
Definition: api.qh:150
#define PROJECTILE_TOUCH(e, t)
Definition: common.qh:27
RES_HEALTH
Definition: ent_cs.qc:126
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
const int MONSTER_ATTACK_MELEE
Definition: sv_monsters.qh:70
#define NULL
Definition: post.qh:17
#define TC(T, sym)
Definition: _all.inc:82
const int MONSTER_ATTACK_RANGED
Definition: sv_monsters.qh:71
#define W_SetupShot_Dir(ent, wepent, s_forward, antilag, recoil, snd, chan, maxdamage, deathtype)
Definition: tracing.qh:31
void monster_makevectors(entity this, entity targ)
Definition: sv_monsters.qc:66
const int PROJECTILE_FIREMINE
Definition: projectiles.qh:22
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float MOVETYPE_FLYMISSILE
Definition: progsdefs.qc:255
IntrusiveList g_projectiles
Definition: common.qh:46
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
bool Monster_Spawn(entity this, bool check_appear, Monster mon)
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
const float SOLID_TRIGGER
Definition: csprogsdefs.qc:245
float RadiusDamage(entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype,.entity weaponentity, entity directhitentity)
Definition: damage.qc:1057
entity realowner
Definition: common.qh:25
setorigin(ent, v)
#define setthink(e, f)
Definition: wyvern.qh:9
#define SOUND(name, path)
Definition: all.qh:30
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
float time
Definition: csprogsdefs.qc:16
const int CH_WEAPON_B
Definition: sound.qh:8
void set_movetype(entity this, int mt)
#define IS_PLAYER(v)
Definition: utils.qh:9
vector v_forward
Definition: csprogsdefs.qc:31
int projectiledeathtype
Definition: common.qh:20