Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
wyvern.qc
Go to the documentation of this file.
1#include "wyvern.qh"
2
3#ifdef SVQC
16
19
20SOUND(WyvernAttack_FIRE, W_Sound("electro_fire"));
21
22METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity weaponentity, int fire))
23{
24 TC(WyvernAttack, thiswep);
25 if (fire & 1)
26 if (time > actor.attack_finished_single[0] || weapon_prepareattack(thiswep, actor, weaponentity, false, 1.2))
27 {
28 monster_makevectors(actor, actor.enemy);
29 if (IS_PLAYER(actor))
30 W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_WyvernAttack_FIRE, CH_WEAPON_B, 0, DEATH_MONSTER_WYVERN.m_id);
31 if (IS_MONSTER(actor))
32 actor.attack_finished_single[0] = actor.anim_finished = time + 1.2;
33
34 entity missile = new(WyvernAttack);
35 missile.owner = missile.realowner = actor;
36 missile.solid = SOLID_TRIGGER;
38 missile.projectiledeathtype = DEATH_MONSTER_WYVERN.m_id;
39 setsize(missile, '-6 -6 -6', '6 6 6');
40 setorigin(missile, actor.origin + actor.view_ofs + v_forward * 14);
41 missile.flags = FL_PROJECTILE;
42 IL_PUSH(g_projectiles, missile);
43 IL_PUSH(g_bot_dodge, missile);
45 missile.avelocity = '300 300 300';
46 missile.nextthink = time + 5;
49 CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true);
50
51 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
52 }
53}
54
55METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor, .entity weaponentity))
56{
57 TC(WyvernAttack, this);
58 return true;
59}
60
89
96
98{
99 w_shotdir = normalize((this.enemy.origin + '0 0 10') - this.origin);
100 Weapon wep = WEP_WYVERN_ATTACK;
101 // TODO
102 .entity weaponentity = weaponentities[0];
103 wep.wr_think(wep, this, weaponentity, 1);
104}
105
106bool M_Wyvern_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
107{
108 switch (attack_type)
109 {
113 //actor.anim_finished = time + 1.2;
114 setanim(actor, actor.anim_shoot, false, true, true);
115 if (actor.animstate_endtime > time)
116 actor.anim_finished = actor.animstate_endtime;
117 else
118 actor.anim_finished = time + 1.2;
119 actor.attack_finished_single[0] = actor.anim_finished + 0.2;
120 return true;
121 }
122 return false;
123}
124
125spawnfunc(monster_wyvern)
126{
127 Monster_Spawn(this, true, MON_WYVERN);
128}
129
130METHOD(Wyvern, mr_think, bool(Wyvern this, entity actor))
131{
132 TC(Wyvern, this);
133 return true;
134}
135
136METHOD(Wyvern, mr_deadthink, bool(Wyvern this, entity actor))
137{
138 TC(Wyvern, this);
139 if (IS_ONGROUND(actor))
140 setanim(actor, actor.anim_die2, true, false, false);
141 return true;
142}
143
144METHOD(Wyvern, mr_pain, float(Wyvern this, entity actor, float damage_take, entity attacker, float deathtype))
145{
146 TC(Wyvern, this);
147 actor.pain_finished = time + 0.5;
148 setanim(actor, actor.anim_pain1, true, true, false);
149 return damage_take;
150}
151
152METHOD(Wyvern, mr_death, bool(Wyvern this, entity actor))
153{
154 TC(Wyvern, this);
155 setanim(actor, actor.anim_die1, false, true, true);
156 actor.velocity.x = 400 * random() - 200;
157 actor.velocity.y = 400 * random() - 200;
158 actor.velocity.z = 100 * random() + 100;
159 return true;
160}
161#endif // SVQC
162#ifdef GAMEQC
163METHOD(Wyvern, mr_anim, bool(Wyvern this, entity actor))
164{
165 TC(Wyvern, this);
166 vector none = '0 0 0';
167 actor.anim_idle = animfixfps(actor, '0 1 1', none);
168 actor.anim_walk = animfixfps(actor, '1 1 1', none);
169 actor.anim_run = animfixfps(actor, '2 1 1', none);
170 actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
171 actor.anim_pain2 = animfixfps(actor, '4 1 2', none); // 0.5 seconds
172 actor.anim_melee = animfixfps(actor, '5 1 5', none); // analyze models and set framerate
173 actor.anim_shoot = animfixfps(actor, '6 1 5', none); // analyze models and set framerate
174 actor.anim_die1 = animfixfps(actor, '7 1 0.5', none); // 2 seconds
175 actor.anim_die2 = animfixfps(actor, '8 1 0.5', none); // 2 seconds
176 return true;
177}
178#endif // GAMEQC
179#ifdef SVQC
180METHOD(Wyvern, mr_setup, bool(Wyvern this, entity actor))
181{
182 TC(Wyvern, this);
183 if (!GetResource(this, RES_HEALTH))
185 if (!actor.speed) actor.speed = autocvar_g_monster_wyvern_speed_walk;
186 if (!actor.speed2) actor.speed2 = autocvar_g_monster_wyvern_speed_run;
187 if (!actor.stopspeed) actor.stopspeed = autocvar_g_monster_wyvern_speed_stop;
188 if (!actor.damageforcescale) actor.damageforcescale = autocvar_g_monster_wyvern_damageforcescale;
189
190 actor.monster_loot = autocvar_g_monster_wyvern_loot;
191 actor.monster_attackfunc = M_Wyvern_Attack;
192
193 return true;
194}
195#endif // SVQC
196#ifdef MENUQC
197METHOD(Wyvern, describe, string(Wyvern this))
198{
199 TC(Wyvern, this);
201 PAR(_("The Wyvern is a flying reptilian monster that glides around hunting for fresh prey."));
202 PAR(_("While fragile, the Wyvern is capable of launching deadly fireballs at the player from a distance, inflicting high damage and causing burning."));
203 return PAGE_TEXT;
204}
205#endif // MENUQC
#define setanim(...)
Definition anim.qh:45
IntrusiveList g_bot_dodge
Definition api.qh:150
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:42
virtual void wr_think()
(SERVER) logic to run every frame
Definition weapon.qh:98
#define IS_PLAYER(s)
Definition player.qh:242
const int FL_PROJECTILE
Definition constants.qh:77
const float SOLID_TRIGGER
float time
vector v_forward
vector origin
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
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:937
float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
Definition damage.qc:968
#define DMG_NOWEP
Definition damage.qh:104
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:155
SetResourceExplicit(ent, RES_ARMOR, ReadByte() *DEC_FACTOR)) ENTCS_PROP(NAME
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define TC(T, sym)
Definition _all.inc:82
entity WarpZone_SearchInRadius(vector org, float rad, float nomonsters, WarpZone_FindRadius_cond_callback_t cb)
Modified findradius aware of warpzones, that only includes entities that meet the "cb" criteria.
Definition common.qc:680
noref entity WarpZone_SearchInRadius_otherent
Free to use in the callback.
Definition common.qh:71
#define MOVE_NOTHING
Definition common.qh:35
float random(void)
vector normalize(vector v)
vector animfixfps(entity e, vector a, vector b)
Definition util.qc:1917
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_FLYMISSILE
Definition movetypes.qh:142
#define IS_ONGROUND(s)
Definition movetypes.qh:16
#define METHOD(cname, name, prototype)
Definition oo.qh:274
#define NULL
Definition post.qh:14
const int PROJECTILE_FIREMINE
#define setthink(e, f)
vector
Definition self.qh:96
entity entity toucher
Definition self.qh:76
#define settouch(e, f)
Definition self.qh:77
int projectiledeathtype
Definition common.qh:33
#define PROJECTILE_TOUCH(e, t)
Definition common.qh:40
IntrusiveList g_projectiles
Definition common.qh:70
const int CH_WEAPON_B
Definition sound.qh:8
string W_Sound(string w_snd)
Definition all.qc:226
#define SOUND(name, path)
Definition all.qh:30
#define spawnfunc(id)
Definition spawnfunc.qh:107
#define PAGE_TEXT
Definition string.qh:651
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:657
#define PAGE_TEXT_INIT()
Definition string.qh:650
const int DAMAGE_AIM
Definition subs.qh:81
entity enemy
Definition sv_ctf.qh:152
void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func)
bool Monster_Spawn(entity this, bool check_appear, Monster mon)
Setup the basic required properties for a monster.
void monster_makevectors(entity this, entity targ)
#define MONSTER_SKILLMOD(mon)
const int MONSTER_ATTACK_MELEE
const int MONSTER_ATTACK_RANGED
entity realowner
vector w_shotdir
Definition tracing.qh:20
#define W_SetupShot_Dir(ent, wepent, s_forward, antilag, recoil, snd, chan, maxdamage, deathtype)
Definition tracing.qh:32
#define IS_MONSTER(v)
Definition utils.qh:23
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
void weapon_thinkf(entity actor,.entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor,.entity weaponentity, int fire) func)
bool weapon_prepareattack(Weapon thiswep, entity actor,.entity weaponentity, bool secondary, float attacktime)
void w_ready(Weapon thiswep, entity actor,.entity weaponentity, int fire)
float autocvar_g_monster_wyvern_attack_fireball_damage
Definition wyvern.qc:7
float autocvar_g_monster_wyvern_health
Definition wyvern.qc:4
string autocvar_g_monster_wyvern_loot
Definition wyvern.qc:5
float autocvar_g_monster_wyvern_speed_stop
Definition wyvern.qc:13
bool M_Wyvern_Attack(int attack_type, entity actor, entity targ,.entity weaponentity)
Definition wyvern.qc:106
float autocvar_g_monster_wyvern_attack_fireball_edgedamage
Definition wyvern.qc:8
float autocvar_g_monster_wyvern_speed_walk
Definition wyvern.qc:15
void M_Wyvern_Attack_Fireball_Touch(entity this, entity toucher)
Definition wyvern.qc:90
float autocvar_g_monster_wyvern_speed_run
Definition wyvern.qc:14
bool M_Wyvern_Attack_Fireball_Explode_cond(entity e)
Definition wyvern.qc:61
void M_Wyvern_Attack_Fireball_Explode(entity this)
Definition wyvern.qc:65
float autocvar_g_monster_wyvern_damageforcescale
Definition wyvern.qc:6
float autocvar_g_monster_wyvern_attack_fireball_force
Definition wyvern.qc:10
void M_Wyvern_Attack_Fireball(entity this)
Definition wyvern.qc:97
float autocvar_g_monster_wyvern_attack_fireball_radius
Definition wyvern.qc:11
float autocvar_g_monster_wyvern_attack_fireball_damagetime
Definition wyvern.qc:9
float autocvar_g_monster_wyvern_attack_fireball_speed
Definition wyvern.qc:12