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
84
91
93{
94 w_shotdir = normalize((this.enemy.origin + '0 0 10') - this.origin);
95 Weapon wep = WEP_WYVERN_ATTACK;
96 // TODO
97 .entity weaponentity = weaponentities[0];
98 wep.wr_think(wep, this, weaponentity, 1);
99}
100
101bool M_Wyvern_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
102{
103 switch (attack_type)
104 {
108 //actor.anim_finished = time + 1.2;
109 setanim(actor, actor.anim_shoot, false, true, true);
110 if (actor.animstate_endtime > time)
111 actor.anim_finished = actor.animstate_endtime;
112 else
113 actor.anim_finished = time + 1.2;
114 actor.attack_finished_single[0] = actor.anim_finished + 0.2;
115 return true;
116 }
117 return false;
118}
119
120spawnfunc(monster_wyvern)
121{
122 Monster_Spawn(this, true, MON_WYVERN);
123}
124
125METHOD(Wyvern, mr_think, bool(Wyvern this, entity actor))
126{
127 TC(Wyvern, this);
128 return true;
129}
130
131METHOD(Wyvern, mr_deadthink, bool(Wyvern this, entity actor))
132{
133 TC(Wyvern, this);
134 if (IS_ONGROUND(actor))
135 setanim(actor, actor.anim_die2, true, false, false);
136 return true;
137}
138
139METHOD(Wyvern, mr_pain, float(Wyvern this, entity actor, float damage_take, entity attacker, float deathtype))
140{
141 TC(Wyvern, this);
142 actor.pain_finished = time + 0.5;
143 setanim(actor, actor.anim_pain1, true, true, false);
144 return damage_take;
145}
146
147METHOD(Wyvern, mr_death, bool(Wyvern this, entity actor))
148{
149 TC(Wyvern, this);
150 setanim(actor, actor.anim_die1, false, true, true);
151 actor.velocity.x = 400 * random() - 200;
152 actor.velocity.y = 400 * random() - 200;
153 actor.velocity.z = 100 * random() + 100;
154 return true;
155}
156#endif // SVQC
157#ifdef GAMEQC
158METHOD(Wyvern, mr_anim, bool(Wyvern this, entity actor))
159{
160 TC(Wyvern, this);
161 vector none = '0 0 0';
162 actor.anim_idle = animfixfps(actor, '0 1 1', none);
163 actor.anim_walk = animfixfps(actor, '1 1 1', none);
164 actor.anim_run = animfixfps(actor, '2 1 1', none);
165 actor.anim_pain1 = animfixfps(actor, '3 1 2', none); // 0.5 seconds
166 actor.anim_pain2 = animfixfps(actor, '4 1 2', none); // 0.5 seconds
167 actor.anim_melee = animfixfps(actor, '5 1 5', none); // analyze models and set framerate
168 actor.anim_shoot = animfixfps(actor, '6 1 5', none); // analyze models and set framerate
169 actor.anim_die1 = animfixfps(actor, '7 1 0.5', none); // 2 seconds
170 actor.anim_die2 = animfixfps(actor, '8 1 0.5', none); // 2 seconds
171 return true;
172}
173#endif // GAMEQC
174#ifdef SVQC
175METHOD(Wyvern, mr_setup, bool(Wyvern this, entity actor))
176{
177 TC(Wyvern, this);
178 if (!GetResource(this, RES_HEALTH))
180 if (!actor.speed) actor.speed = autocvar_g_monster_wyvern_speed_walk;
181 if (!actor.speed2) actor.speed2 = autocvar_g_monster_wyvern_speed_run;
182 if (!actor.stopspeed) actor.stopspeed = autocvar_g_monster_wyvern_speed_stop;
183 if (!actor.damageforcescale) actor.damageforcescale = autocvar_g_monster_wyvern_damageforcescale;
184
185 actor.monster_loot = autocvar_g_monster_wyvern_loot;
186 actor.monster_attackfunc = M_Wyvern_Attack;
187
188 return true;
189}
190#endif // SVQC
191#ifdef MENUQC
192METHOD(Wyvern, describe, string(Wyvern this))
193{
194 TC(Wyvern, this);
196 PAR(_("The Wyvern is a flying reptilian monster that glides around hunting for fresh prey."));
197 PAR(_("While fragile, the Wyvern is capable of launching deadly fireballs at the player from a distance, inflicting high damage and causing burning."));
198 return PAGE_TEXT;
199}
200#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.
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
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:85
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:943
float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
Definition damage.qc:974
#define DMG_NOWEP
Definition damage.qh:104
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:120
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define FOREACH_ENTITY_RADIUS(org, dist, cond, body)
Definition iter.qh:160
#define TC(T, sym)
Definition _all.inc:82
float random(void)
vector normalize(vector v)
vector animfixfps(entity e, vector a, vector b)
Definition util.qc:1905
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_FLYMISSILE
Definition movetypes.qh:138
#define IS_ONGROUND(s)
Definition movetypes.qh:16
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define NULL
Definition post.qh:14
const int PROJECTILE_FIREMINE
#define setthink(e, f)
vector
Definition self.qh:92
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
int projectiledeathtype
Definition common.qh:21
#define PROJECTILE_TOUCH(e, t)
Definition common.qh:28
IntrusiveList g_projectiles
Definition common.qh:58
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:96
#define PAGE_TEXT
Definition string.qh:642
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:648
#define PAGE_TEXT_INIT()
Definition string.qh:641
const int DAMAGE_AIM
Definition subs.qh:81
entity enemy
Definition sv_ctf.qh:153
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:101
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:85
float autocvar_g_monster_wyvern_speed_run
Definition wyvern.qc:14
void M_Wyvern_Attack_Fireball_Explode(entity this)
Definition wyvern.qc:61
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:92
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