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 animstate_endtime
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 151 of file golem.qc.

152{
153 switch(attack_type)
154 {
156 {
157 setanim(actor, ((random() >= 0.5) ? actor.anim_melee2 : actor.anim_melee3), false, true, true);
158 int swing_cnt = bound(1, floor(random() * 4), 3);
159 Monster_Delay(actor, swing_cnt, 0.5, M_Golem_Attack_Swing);
160 actor.anim_finished = actor.attack_finished_single[0] = time + (0.5 * swing_cnt); // set this for the delay
161 return true;
162 }
164 {
165 float randomness = random();
166
167 if(time < actor.golem_lastattack || !IS_ONGROUND(actor))
168 return false;
169
170 if(randomness <= 0.5 && vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_golem_attack_smash_range))
171 {
172 setanim(actor, actor.anim_melee1, false, true, true);
173 Monster_Delay(actor, 1, 1.1, M_Golem_Attack_Smash);
174 if(actor.animstate_endtime > time)
175 actor.anim_finished = actor.animstate_endtime;
176 else
177 actor.anim_finished = time + 1.2;
178 actor.attack_finished_single[0] = actor.anim_finished + 0.2;
179 actor.state = MONSTER_ATTACK_MELEE; // kinda a melee attack
180 actor.golem_lastattack = time + 3 + random() * 1.5;
181 return true;
182 }
183 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
184 {
185 setanim(actor, actor.anim_melee2, true, true, false);
186 actor.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general
187 actor.attack_finished_single[0] = time + 1.1;
188 actor.anim_finished = 1.1;
189 actor.golem_lastattack = time + 3 + random() * 1.5;
191 return true;
192 }
193
194 return false;
195 }
196 }
197
198 return false;
199}
#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:40
void M_Golem_Attack_Lightning(entity this)
Definition golem.qc:109
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 109 of file golem.qc.

110{
111 entity gren;
112
113 monster_makevectors(this, this.enemy);
114
115 gren = new(grenade);
116 gren.owner = gren.realowner = this;
117 gren.bot_dodge = true;
121 gren.projectiledeathtype = DEATH_MONSTER_GOLEM_ZAP.m_id;
122 setorigin(gren, CENTER_OR_VIEWOFS(this));
123 setsize(gren, '-8 -8 -8', '8 8 8');
124 gren.scale = 2.5;
125
126 gren.cnt = time + 5;
127 gren.nextthink = time;
131
132 gren.takedamage = DAMAGE_YES;
133 SetResourceExplicit(gren, RES_HEALTH, 50);
134 gren.damageforcescale = 0;
135 gren.event_damage = M_Golem_Attack_Lightning_Damage;
136 gren.damagedbycontents = true;
138 gren.missile_flags = MIF_SPLASH | MIF_ARC;
140
141 gren.angles = vectoangles (gren.velocity);
142 gren.flags = FL_PROJECTILE;
143 IL_PUSH(g_projectiles, gren);
144 IL_PUSH(g_bot_dodge, gren);
145
147}
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:135
void M_Golem_Attack_Lightning_Explode_use(entity this, entity actor, entity trigger)
Definition golem.qc:73
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:92
void M_Golem_Attack_Lightning_Think(entity this)
Definition golem.qc:99
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:78
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:192
#define CENTER_OR_VIEWOFS(ent)
Definition utils.qh:29

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 78 of file golem.qc.

79{
80 if (GetResource(this, RES_HEALTH) <= 0)
81 return;
82
83 if (!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
84 return; // g_projectiles_damage says to halt
85
86 TakeResource(this, RES_HEALTH, damage);
87
88 if (GetResource(this, RES_HEALTH) <= 0)
89 W_PrepareExplosionByDamage(this, attacker, adaptor_think2use);
90}
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 47 of file golem.qc.

48{
49 sound(this, CH_SHOTS, SND_MON_GOLEM_LIGHTNING_IMPACT, VOL_BASE, ATTEN_NORM);
50 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
51
52 this.event_damage = func_null;
53 this.takedamage = DAMAGE_NO;
55 this.velocity = '0 0 0';
56
58 this.velocity = this.oldvelocity;
59
62
64 {
65 te_csqc_lightningarc(this.origin, it.origin);
66 Damage(it, this, this.realowner, (autocvar_g_monster_golem_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_GOLEM_ZAP.m_id, DMG_NOWEP, it.origin, '0 0 0');
67 });
68
69 setthink(this, SUB_Remove);
70 this.nextthink = time + 0.2;
71}
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:981
#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:124
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 73 of file golem.qc.

74{
76}
void M_Golem_Attack_Lightning_Explode(entity this, entity directhitentity)
Definition golem.qc:47

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 99 of file golem.qc.

100{
101 this.nextthink = time;
102 if (time > this.cnt)
103 {
105 return;
106 }
107}
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 92 of file golem.qc.

93{
95
96 this.use(this, NULL, toucher);
97}
#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);
37 delete(dmgent);
38}
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 40 of file golem.qc.

41{
42 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);
43}
float autocvar_g_monster_golem_attack_claw_damage
Definition golem.qc:10
vector anim_melee2
Definition monster.qh:30
vector anim_melee3
Definition monster.qh:31
bool Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, bool dostop)
float 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 201 of file golem.qc.

201{ Monster_Spawn(this, true, MON_GOLEM); }
bool Monster_Spawn(entity this, bool check_appear, Monster mon)

References Monster_Spawn().

◆ spawnfunc() [2/2]

spawnfunc ( monster_shambler )

Definition at line 203 of file golem.qc.

203{ spawnfunc_monster_golem(this); }

Variable Documentation

◆ animstate_endtime

float animstate_endtime

Definition at line 262 of file golem.qc.

◆ 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 149 of file golem.qc.