Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
golem.qc File Reference
#include "golem.qh"
#include <common/effects/qc/_mod.qh>
Include dependency graph for golem.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool M_Golem_Attack (int attack_type, entity actor, entity targ,.entity weaponentity)
void M_Golem_Attack_Lightning (entity this)
void M_Golem_Attack_Lightning_Damage (entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void M_Golem_Attack_Lightning_Explode (entity this, entity directhitentity)
void M_Golem_Attack_Lightning_Explode_use (entity this, entity actor, entity trigger)
void M_Golem_Attack_Lightning_Think (entity this)
void M_Golem_Attack_Lightning_Touch (entity this, entity toucher)
void M_Golem_Attack_Smash (entity this)
void M_Golem_Attack_Swing (entity this)
 spawnfunc (monster_golem)
 spawnfunc (monster_shambler)

Variables

float autocvar_g_monster_golem_attack_claw_damage
float autocvar_g_monster_golem_attack_lightning_damage
float autocvar_g_monster_golem_attack_lightning_damage_zap = 15
float autocvar_g_monster_golem_attack_lightning_force
float autocvar_g_monster_golem_attack_lightning_radius
float autocvar_g_monster_golem_attack_lightning_radius_zap
float autocvar_g_monster_golem_attack_lightning_speed
float autocvar_g_monster_golem_attack_lightning_speed_up
float autocvar_g_monster_golem_attack_smash_damage
float autocvar_g_monster_golem_attack_smash_force = 100
float autocvar_g_monster_golem_attack_smash_range = 200
float autocvar_g_monster_golem_damageforcescale = 0.1
float autocvar_g_monster_golem_health
string autocvar_g_monster_golem_loot = "health_mega electro"
float autocvar_g_monster_golem_speed_run
float autocvar_g_monster_golem_speed_stop
float autocvar_g_monster_golem_speed_walk
float golem_lastattack
int state

Function Documentation

◆ M_Golem_Attack()

bool M_Golem_Attack ( int attack_type,
entity actor,
entity targ,
.entity weaponentity )

Definition at line 172 of file golem.qc.

173{
174 switch (attack_type)
175 {
177 {
178 setanim(actor, ((random() >= 0.5) ? actor.anim_melee2 : actor.anim_melee3), false, true, true);
179 int swing_cnt = bound(1, floor(random() * 4), 3);
180 Monster_Delay(actor, swing_cnt, 0.5, M_Golem_Attack_Swing);
181 actor.anim_finished = actor.attack_finished_single[0] = time + (0.5 * swing_cnt); // set this for the delay
182 return true;
183 }
185 {
186 float randomness = random();
187
188 if (time < actor.golem_lastattack || !IS_ONGROUND(actor))
189 return false;
190
191 if (randomness <= 0.5 && vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_golem_attack_smash_range))
192 {
193 setanim(actor, actor.anim_melee1, false, true, true);
194 Monster_Delay(actor, 1, 1.1, M_Golem_Attack_Smash);
195 if (actor.animstate_endtime > time)
196 actor.anim_finished = actor.animstate_endtime;
197 else
198 actor.anim_finished = time + 1.2;
199 actor.attack_finished_single[0] = actor.anim_finished + 0.2;
200 actor.state = MONSTER_ATTACK_MELEE; // kinda a melee attack
201 actor.golem_lastattack = time + 3 + random() * 1.5;
202 return true;
203 }
204 else if (randomness <= 0.1 && vdist(actor.enemy.origin - actor.origin, >=, autocvar_g_monster_golem_attack_smash_range * 1.5)) // small chance, don't want this spammed
205 {
206 setanim(actor, actor.anim_melee2, true, true, false);
207 actor.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general
208 actor.attack_finished_single[0] = time + 1.1;
209 actor.anim_finished = 1.1;
210 actor.golem_lastattack = time + 3 + random() * 1.5;
212 return true;
213 }
214 return false;
215 }
216 }
217
218 return false;
219}
#define setanim(...)
Definition anim.qh:45
float time
float autocvar_g_monster_golem_attack_smash_range
Definition golem.qc:9
void M_Golem_Attack_Smash(entity this)
Definition golem.qc:24
void M_Golem_Attack_Swing(entity this)
Definition golem.qc:49
void M_Golem_Attack_Lightning(entity this)
Definition golem.qc:132
float bound(float min, float value, float max)
float random(void)
float floor(float f)
#define IS_ONGROUND(s)
Definition movetypes.qh:16
void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func)
const int MONSTER_ATTACK_MELEE
const int MONSTER_ATTACK_RANGED
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8

References autocvar_g_monster_golem_attack_smash_range, bound(), entity(), floor(), IS_ONGROUND, M_Golem_Attack_Lightning(), M_Golem_Attack_Smash(), M_Golem_Attack_Swing(), MONSTER_ATTACK_MELEE, MONSTER_ATTACK_RANGED, Monster_Delay(), random(), setanim, time, and vdist.

◆ M_Golem_Attack_Lightning()

void M_Golem_Attack_Lightning ( entity this)

Definition at line 132 of file golem.qc.

133{
134 monster_makevectors(this, this.enemy);
135
136 entity gren = new(grenade);
137 gren.owner = gren.realowner = this;
138 gren.bot_dodge = true;
142 gren.projectiledeathtype = DEATH_MONSTER_GOLEM_ZAP.m_id;
143 setorigin(gren, CENTER_OR_VIEWOFS(this));
144 setsize(gren, '-8 -8 -8', '8 8 8');
145 gren.scale = 2.5;
146
147 gren.cnt = time + 5;
148 gren.nextthink = time;
152
153 gren.takedamage = DAMAGE_YES;
154 SetResourceExplicit(gren, RES_HEALTH, 50);
155 gren.damageforcescale = 0;
156 gren.event_damage = M_Golem_Attack_Lightning_Damage;
157 gren.damagedbycontents = true;
159 gren.missile_flags = MIF_SPLASH | MIF_ARC;
161
162 gren.angles = vectoangles(gren.velocity);
163 gren.flags = FL_PROJECTILE;
164 IL_PUSH(g_projectiles, gren);
165 IL_PUSH(g_bot_dodge, gren);
166
168}
IntrusiveList g_bot_dodge
Definition api.qh:150
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
const int FL_PROJECTILE
Definition constants.qh:85
vector v_up
vector v_forward
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
IntrusiveList g_damagedbycontents
Definition damage.qh:143
void M_Golem_Attack_Lightning_Explode_use(entity this, entity actor, entity trigger)
Definition golem.qc:97
float autocvar_g_monster_golem_attack_lightning_damage
Definition golem.qc:11
void M_Golem_Attack_Lightning_Touch(entity this, entity toucher)
Definition golem.qc:115
void M_Golem_Attack_Lightning_Think(entity this)
Definition golem.qc:122
float autocvar_g_monster_golem_attack_lightning_speed_up
Definition golem.qc:17
float autocvar_g_monster_golem_attack_lightning_speed
Definition golem.qc:16
void M_Golem_Attack_Lightning_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition golem.qc:102
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
vector vectoangles(vector v)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_BOUNCE
Definition movetypes.qh:139
const int PROJECTILE_GOLEM_LIGHTNING
#define setthink(e, f)
#define settouch(e, f)
Definition self.qh:73
const int MIF_SPLASH
Definition common.qh:46
IntrusiveList g_projectiles
Definition common.qh:58
const int MIF_ARC
Definition common.qh:47
#define PROJECTILE_MAKETRIGGER(e)
Definition common.qh:34
const int DAMAGE_YES
Definition subs.qh:80
entity enemy
Definition sv_ctf.qh:153
void monster_makevectors(entity this, entity targ)
void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread, float forceAbsolute)
Definition tracing.qc:185
#define CENTER_OR_VIEWOFS(ent)
Definition utils.qh:31

References autocvar_g_monster_golem_attack_lightning_damage, autocvar_g_monster_golem_attack_lightning_speed, autocvar_g_monster_golem_attack_lightning_speed_up, CENTER_OR_VIEWOFS, CSQCProjectile(), DAMAGE_YES, enemy, entity(), FL_PROJECTILE, g_bot_dodge, g_damagedbycontents, g_projectiles, IL_PUSH(), M_Golem_Attack_Lightning_Damage(), M_Golem_Attack_Lightning_Explode_use(), M_Golem_Attack_Lightning_Think(), M_Golem_Attack_Lightning_Touch(), MIF_ARC, MIF_SPLASH, monster_makevectors(), MOVETYPE_BOUNCE, PROJECTILE_GOLEM_LIGHTNING, PROJECTILE_MAKETRIGGER, set_movetype(), SetResourceExplicit(), setthink, settouch, time, v_forward, v_up, vectoangles(), and W_SetupProjVelocity_Explicit().

Referenced by M_Golem_Attack().

◆ M_Golem_Attack_Lightning_Damage()

void M_Golem_Attack_Lightning_Damage ( entity this,
entity inflictor,
entity attacker,
float damage,
int deathtype,
.entity weaponentity,
vector hitloc,
vector force )

Definition at line 102 of file golem.qc.

103{
104 if (GetResource(this, RES_HEALTH) <= 0)
105 return;
106 if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
107 return; // g_projectiles_damage says to halt
108
109 TakeResource(this, RES_HEALTH, damage);
110
111 if (GetResource(this, RES_HEALTH) <= 0)
112 W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
113}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype, float exception)
Definition common.qc:45
void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) explode)
Definition common.qc:87

References entity(), GetResource(), TakeResource(), vector, W_CheckProjectileDamage(), and W_PrepareExplosionByDamage().

Referenced by M_Golem_Attack_Lightning().

◆ M_Golem_Attack_Lightning_Explode()

void M_Golem_Attack_Lightning_Explode ( entity this,
entity directhitentity )

Definition at line 56 of file golem.qc.

57{
58 sound(this, CH_SHOTS, SND_MON_GOLEM_LIGHTNING_IMPACT, VOL_BASE, ATTEN_NORM);
59 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
60
61 this.event_damage = func_null;
62 this.takedamage = DAMAGE_NO;
64 this.velocity = '0 0 0';
65
66 if (this.move_movetype == MOVETYPE_NONE)
67 this.velocity = this.oldvelocity;
68
69 RadiusDamage(this, this.realowner,
73 NULL,
74 NULL,
78 directhitentity
79 );
80
82 {
83 te_csqc_lightningarc(this.origin, it.origin);
84 Damage(it, this, this.realowner,
85 autocvar_g_monster_golem_attack_lightning_damage_zap * MONSTER_SKILLMOD(this),
86 DEATH_MONSTER_GOLEM_ZAP.m_id,
87 DMG_NOWEP,
88 it.origin,
89 '0 0 0'
90 );
91 });
92
93 setthink(this, SUB_Remove);
94 this.nextthink = time + 0.2;
95}
vector velocity
float nextthink
vector origin
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
#define DMG_NOWEP
Definition damage.qh:104
void SUB_Remove(entity this)
Remove entity.
Definition defer.qh:13
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:120
float autocvar_g_monster_golem_attack_lightning_force
Definition golem.qc:13
float autocvar_g_monster_golem_attack_lightning_radius_zap
Definition golem.qc:15
float autocvar_g_monster_golem_attack_lightning_radius
Definition golem.qc:14
#define FOREACH_ENTITY_RADIUS(org, dist, cond, body)
Definition iter.qh:160
const int MOVETYPE_NONE
Definition movetypes.qh:129
float move_movetype
Definition movetypes.qh:76
var void func_null()
#define NULL
Definition post.qh:14
vector oldvelocity
Definition main.qh:42
int projectiledeathtype
Definition common.qh:21
const float VOL_BASE
Definition sound.qh:36
const int CH_SHOTS
Definition sound.qh:14
const float ATTEN_NORM
Definition sound.qh:30
#define sound(e, c, s, v, a)
Definition sound.qh:52
const int DAMAGE_NO
Definition subs.qh:79
float takedamage
Definition subs.qh:78
entity realowner

References ATTEN_NORM, autocvar_g_monster_golem_attack_lightning_damage, autocvar_g_monster_golem_attack_lightning_force, autocvar_g_monster_golem_attack_lightning_radius, autocvar_g_monster_golem_attack_lightning_radius_zap, CH_SHOTS, DAMAGE_NO, DMG_NOWEP, entity(), FOREACH_ENTITY_RADIUS, func_null(), move_movetype, MOVETYPE_NONE, nextthink, NULL, oldvelocity, origin, projectiledeathtype, RadiusDamage(), realowner, Send_Effect(), set_movetype(), setthink, sound, SUB_Remove(), takedamage, time, velocity, and VOL_BASE.

Referenced by M_Golem_Attack_Lightning_Explode_use(), and M_Golem_Attack_Lightning_Think().

◆ M_Golem_Attack_Lightning_Explode_use()

void M_Golem_Attack_Lightning_Explode_use ( entity this,
entity actor,
entity trigger )

Definition at line 97 of file golem.qc.

98{
100}
void M_Golem_Attack_Lightning_Explode(entity this, entity directhitentity)
Definition golem.qc:56

References entity(), and M_Golem_Attack_Lightning_Explode().

Referenced by M_Golem_Attack_Lightning().

◆ M_Golem_Attack_Lightning_Think()

void M_Golem_Attack_Lightning_Think ( entity this)

Definition at line 122 of file golem.qc.

123{
124 this.nextthink = time;
125 if (time > this.cnt)
126 {
128 return;
129 }
130}
float cnt
Definition powerups.qc:24

References cnt, entity(), M_Golem_Attack_Lightning_Explode(), nextthink, NULL, and time.

Referenced by M_Golem_Attack_Lightning().

◆ M_Golem_Attack_Lightning_Touch()

void M_Golem_Attack_Lightning_Touch ( entity this,
entity toucher )

Definition at line 115 of file golem.qc.

116{
118
119 this.use(this, NULL, toucher);
120}
#define use
entity entity toucher
Definition self.qh:72
#define PROJECTILE_TOUCH(e, t)
Definition common.qh:28

References entity(), NULL, PROJECTILE_TOUCH, toucher, and use.

Referenced by M_Golem_Attack_Lightning().

◆ M_Golem_Attack_Smash()

void M_Golem_Attack_Smash ( entity this)

Definition at line 24 of file golem.qc.

25{
26 makevectors(this.angles);
27 Send_Effect(EFFECT_EXPLOSION_MEDIUM, (this.origin + (v_forward * 150)) - ('0 0 1' * this.maxs.z), '0 0 0', 1);
28 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
29
30 vector loc = this.origin + v_forward * 50;
31
32 entity dmgent = spawn();
33 dmgent.owner = dmgent.realowner = this;
34 setorigin(dmgent, loc);
35 RadiusDamage(dmgent, this,
39 this,
40 NULL,
42 DEATH_MONSTER_GOLEM_SMASH.m_id,
44 NULL
45 );
46 delete(dmgent);
47}
vector maxs
#define spawn
ent angles
Definition ent_cs.qc:121
float autocvar_g_monster_golem_attack_smash_damage
Definition golem.qc:7
float autocvar_g_monster_golem_attack_smash_force
Definition golem.qc:8
#define makevectors
Definition post.qh:21
vector
Definition self.qh:92
#define MONSTER_SKILLMOD(mon)

References angles, ATTEN_NORM, autocvar_g_monster_golem_attack_smash_damage, autocvar_g_monster_golem_attack_smash_force, autocvar_g_monster_golem_attack_smash_range, CH_SHOTS, DMG_NOWEP, entity(), makevectors, maxs, MONSTER_SKILLMOD, NULL, origin, RadiusDamage(), Send_Effect(), sound, spawn, v_forward, vector, and VOL_BASE.

Referenced by M_Golem_Attack().

◆ M_Golem_Attack_Swing()

void M_Golem_Attack_Swing ( entity this)

Definition at line 49 of file golem.qc.

50{
51 Monster_Attack_Melee(this, this.enemy, autocvar_g_monster_golem_attack_claw_damage, ((random() >= 0.5) ? this.anim_melee2 : this.anim_melee3), this.attack_range, 0.8, DEATH_MONSTER_GOLEM_CLAW.m_id, true);
52}
float autocvar_g_monster_golem_attack_claw_damage
Definition golem.qc:10
vector anim_melee2
Definition monster.qh:29
vector anim_melee3
Definition monster.qh:30
bool Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, bool dostop)
float attack_range
melee attack if closer, ranged attack if further away (TODO: separate ranged attack range?...

References anim_melee2, anim_melee3, attack_range, autocvar_g_monster_golem_attack_claw_damage, enemy, entity(), Monster_Attack_Melee(), and random().

Referenced by M_Golem_Attack().

◆ spawnfunc() [1/2]

spawnfunc ( monster_golem )

Definition at line 221 of file golem.qc.

222{
223 Monster_Spawn(this, true, MON_GOLEM);
224}
bool Monster_Spawn(entity this, bool check_appear, Monster mon)
Setup the basic required properties for a monster.

References Monster_Spawn().

◆ spawnfunc() [2/2]

spawnfunc ( monster_shambler )

Definition at line 226 of file golem.qc.

227{
228 spawnfunc_monster_golem(this);
229}

Variable Documentation

◆ autocvar_g_monster_golem_attack_claw_damage

float autocvar_g_monster_golem_attack_claw_damage

Definition at line 10 of file golem.qc.

Referenced by M_Golem_Attack_Swing().

◆ autocvar_g_monster_golem_attack_lightning_damage

float autocvar_g_monster_golem_attack_lightning_damage

Definition at line 11 of file golem.qc.

Referenced by M_Golem_Attack_Lightning(), and M_Golem_Attack_Lightning_Explode().

◆ autocvar_g_monster_golem_attack_lightning_damage_zap

float autocvar_g_monster_golem_attack_lightning_damage_zap = 15

Definition at line 12 of file golem.qc.

◆ autocvar_g_monster_golem_attack_lightning_force

float autocvar_g_monster_golem_attack_lightning_force

Definition at line 13 of file golem.qc.

Referenced by M_Golem_Attack_Lightning_Explode().

◆ autocvar_g_monster_golem_attack_lightning_radius

float autocvar_g_monster_golem_attack_lightning_radius

Definition at line 14 of file golem.qc.

Referenced by M_Golem_Attack_Lightning_Explode().

◆ autocvar_g_monster_golem_attack_lightning_radius_zap

float autocvar_g_monster_golem_attack_lightning_radius_zap

Definition at line 15 of file golem.qc.

Referenced by M_Golem_Attack_Lightning_Explode().

◆ autocvar_g_monster_golem_attack_lightning_speed

float autocvar_g_monster_golem_attack_lightning_speed

Definition at line 16 of file golem.qc.

Referenced by M_Golem_Attack_Lightning().

◆ autocvar_g_monster_golem_attack_lightning_speed_up

float autocvar_g_monster_golem_attack_lightning_speed_up

Definition at line 17 of file golem.qc.

Referenced by M_Golem_Attack_Lightning().

◆ autocvar_g_monster_golem_attack_smash_damage

float autocvar_g_monster_golem_attack_smash_damage

Definition at line 7 of file golem.qc.

Referenced by M_Golem_Attack_Smash().

◆ autocvar_g_monster_golem_attack_smash_force

float autocvar_g_monster_golem_attack_smash_force = 100

Definition at line 8 of file golem.qc.

Referenced by M_Golem_Attack_Smash().

◆ autocvar_g_monster_golem_attack_smash_range

float autocvar_g_monster_golem_attack_smash_range = 200

Definition at line 9 of file golem.qc.

Referenced by M_Golem_Attack(), and M_Golem_Attack_Smash().

◆ autocvar_g_monster_golem_damageforcescale

float autocvar_g_monster_golem_damageforcescale = 0.1

Definition at line 6 of file golem.qc.

◆ autocvar_g_monster_golem_health

float autocvar_g_monster_golem_health

Definition at line 4 of file golem.qc.

◆ autocvar_g_monster_golem_loot

string autocvar_g_monster_golem_loot = "health_mega electro"

Definition at line 5 of file golem.qc.

◆ autocvar_g_monster_golem_speed_run

float autocvar_g_monster_golem_speed_run

Definition at line 19 of file golem.qc.

◆ autocvar_g_monster_golem_speed_stop

float autocvar_g_monster_golem_speed_stop

Definition at line 18 of file golem.qc.

◆ autocvar_g_monster_golem_speed_walk

float autocvar_g_monster_golem_speed_walk

Definition at line 20 of file golem.qc.

◆ golem_lastattack

float golem_lastattack

Definition at line 22 of file golem.qc.

◆ state

int state

Definition at line 170 of file golem.qc.