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

Go to the source code of this file.

Functions

bool M_Zombie_Attack (int attack_type, entity actor, entity targ,.entity weaponentity)
void M_Zombie_Attack_Leap_Touch (entity this, entity toucher)
bool M_Zombie_Defend_Block (entity this)
void M_Zombie_Defend_Block_End (entity this)
 spawnfunc (monster_zombie)

Variables

float autocvar_g_monster_zombie_attack_leap_damage
float autocvar_g_monster_zombie_attack_leap_delay
float autocvar_g_monster_zombie_attack_leap_force
float autocvar_g_monster_zombie_attack_leap_speed
float autocvar_g_monster_zombie_attack_melee_damage
float autocvar_g_monster_zombie_attack_melee_delay
float autocvar_g_monster_zombie_damageforcescale = 0.55
float autocvar_g_monster_zombie_health
string autocvar_g_monster_zombie_loot = "health_medium"
float autocvar_g_monster_zombie_speed_run
float autocvar_g_monster_zombie_speed_stop
float autocvar_g_monster_zombie_speed_walk

Function Documentation

◆ M_Zombie_Attack()

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

Definition at line 68 of file zombie.qc.

69{
70 switch (attack_type)
71 {
73 {
74 if (random() < 0.3 && GetResource(actor, RES_HEALTH) < 75 && GetResource(actor.enemy, RES_HEALTH) > 10)
75 return M_Zombie_Defend_Block(actor);
76
77 float anim_chance = random();
78 vector chosen_anim;
79 if (anim_chance < 0.33)
80 chosen_anim = actor.anim_melee1;
81 else if (anim_chance < 0.66)
82 chosen_anim = actor.anim_melee2;
83 else
84 chosen_anim = actor.anim_melee3;
85
86 return Monster_Attack_Melee(actor, actor.enemy, autocvar_g_monster_zombie_attack_melee_damage, chosen_anim, actor.attack_range, autocvar_g_monster_zombie_attack_melee_delay, DEATH_MONSTER_ZOMBIE_MELEE.m_id, true);
87 }
89 makevectors(actor.angles);
91 }
92 return false;
93}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
vector v_forward
float random(void)
#define makevectors
Definition post.qh:21
vector
Definition self.qh:92
bool Monster_Attack_Melee(entity this, entity targ, float damg, vector anim, float er, float animtime, int deathtype, bool dostop)
bool Monster_Attack_Leap(entity this, vector anm, void(entity this, entity toucher) touchfunc, vector vel, float animtime)
const int MONSTER_ATTACK_MELEE
const int MONSTER_ATTACK_RANGED
void M_Zombie_Attack_Leap_Touch(entity this, entity toucher)
Definition zombie.qc:17
float autocvar_g_monster_zombie_attack_melee_delay
Definition zombie.qc:8
float autocvar_g_monster_zombie_attack_leap_delay
Definition zombie.qc:12
float autocvar_g_monster_zombie_attack_melee_damage
Definition zombie.qc:7
bool M_Zombie_Defend_Block(entity this)
Definition zombie.qc:55
float autocvar_g_monster_zombie_attack_leap_speed
Definition zombie.qc:11

References autocvar_g_monster_zombie_attack_leap_delay, autocvar_g_monster_zombie_attack_leap_speed, autocvar_g_monster_zombie_attack_melee_damage, autocvar_g_monster_zombie_attack_melee_delay, entity(), GetResource(), M_Zombie_Attack_Leap_Touch(), M_Zombie_Defend_Block(), makevectors, Monster_Attack_Leap(), MONSTER_ATTACK_MELEE, Monster_Attack_Melee(), MONSTER_ATTACK_RANGED, random(), v_forward, and vector.

◆ M_Zombie_Attack_Leap_Touch()

void M_Zombie_Attack_Leap_Touch ( entity this,
entity toucher )

Definition at line 17 of file zombie.qc.

18{
19 if (GetResource(this, RES_HEALTH) <= 0)
20 return;
21
22 vector angles_face;
23
24 if (toucher.takedamage)
25 {
26 angles_face = vectoangles(this.moveto - this.origin);
27 angles_face = normalize(angles_face) * autocvar_g_monster_zombie_attack_leap_force;
28 Damage(toucher, this, this.realowner,
30 DEATH_MONSTER_ZOMBIE_JUMP.m_id,
32 toucher.origin,
33 angles_face
34 );
35 settouch(this, Monster_Touch); // instantly turn it off to stop damage spam
36 this.state = 0;
37 }
38
40 {
41 this.state = 0;
43 }
44}
float trace_dphitcontents
vector origin
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition damage.qc:493
#define DMG_NOWEP
Definition damage.qh:104
int state
vector vectoangles(vector v)
vector normalize(vector v)
vector moveto
Definition movelib.qc:4
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
void Monster_Touch(entity this, entity toucher)
#define MONSTER_SKILLMOD(mon)
entity realowner
float autocvar_g_monster_zombie_attack_leap_damage
Definition zombie.qc:9
float autocvar_g_monster_zombie_attack_leap_force
Definition zombie.qc:10

References autocvar_g_monster_zombie_attack_leap_damage, autocvar_g_monster_zombie_attack_leap_force, Damage(), DMG_NOWEP, entity(), GetResource(), MONSTER_SKILLMOD, Monster_Touch(), moveto, normalize(), origin, realowner, settouch, state, toucher, trace_dphitcontents, vectoangles(), and vector.

Referenced by M_Zombie_Attack().

◆ M_Zombie_Defend_Block()

bool M_Zombie_Defend_Block ( entity this)

Definition at line 55 of file zombie.qc.

56{
58 this.state = MONSTER_ATTACK_MELEE; // freeze monster
59 this.attack_finished_single[0] = time + 2.1;
61 setanim(this, this.anim_blockstart, false, true, true);
62
64
65 return true;
66}
#define setanim(...)
Definition anim.qh:45
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
float time
RES_ARMOR
Definition ent_cs.qc:130
vector anim_blockstart
Definition monster.qh:27
void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func)
float anim_finished
will be phased out when we have proper animations system
float attack_finished_single[MAX_WEAPONSLOTS]
void M_Zombie_Defend_Block_End(entity this)
Definition zombie.qc:46

References anim_blockstart, anim_finished, attack_finished_single, entity(), M_Zombie_Defend_Block_End(), MONSTER_ATTACK_MELEE, Monster_Delay(), RES_ARMOR, setanim, SetResourceExplicit(), state, and time.

Referenced by M_Zombie_Attack().

◆ M_Zombie_Defend_Block_End()

void M_Zombie_Defend_Block_End ( entity this)

Definition at line 46 of file zombie.qc.

47{
48 if (GetResource(this, RES_HEALTH) <= 0)
49 return;
50
51 setanim(this, this.anim_blockend, false, true, true);
53}
vector anim_blockend
Definition monster.qh:26
float autocvar_g_monsters_armor_blockpercent

References anim_blockend, autocvar_g_monsters_armor_blockpercent, entity(), GetResource(), RES_ARMOR, setanim, and SetResourceExplicit().

Referenced by M_Zombie_Defend_Block().

◆ spawnfunc()

spawnfunc ( monster_zombie )

Definition at line 95 of file zombie.qc.

96{
97 Monster_Spawn(this, true, MON_ZOMBIE);
98}
bool Monster_Spawn(entity this, bool check_appear, Monster mon)
Setup the basic required properties for a monster.

References Monster_Spawn().

Variable Documentation

◆ autocvar_g_monster_zombie_attack_leap_damage

float autocvar_g_monster_zombie_attack_leap_damage

Definition at line 9 of file zombie.qc.

Referenced by M_Zombie_Attack_Leap_Touch().

◆ autocvar_g_monster_zombie_attack_leap_delay

float autocvar_g_monster_zombie_attack_leap_delay

Definition at line 12 of file zombie.qc.

Referenced by M_Zombie_Attack().

◆ autocvar_g_monster_zombie_attack_leap_force

float autocvar_g_monster_zombie_attack_leap_force

Definition at line 10 of file zombie.qc.

Referenced by M_Zombie_Attack_Leap_Touch().

◆ autocvar_g_monster_zombie_attack_leap_speed

float autocvar_g_monster_zombie_attack_leap_speed

Definition at line 11 of file zombie.qc.

Referenced by M_Zombie_Attack().

◆ autocvar_g_monster_zombie_attack_melee_damage

float autocvar_g_monster_zombie_attack_melee_damage

Definition at line 7 of file zombie.qc.

Referenced by M_Zombie_Attack().

◆ autocvar_g_monster_zombie_attack_melee_delay

float autocvar_g_monster_zombie_attack_melee_delay

Definition at line 8 of file zombie.qc.

Referenced by M_Zombie_Attack().

◆ autocvar_g_monster_zombie_damageforcescale

float autocvar_g_monster_zombie_damageforcescale = 0.55

Definition at line 6 of file zombie.qc.

◆ autocvar_g_monster_zombie_health

float autocvar_g_monster_zombie_health

Definition at line 4 of file zombie.qc.

◆ autocvar_g_monster_zombie_loot

string autocvar_g_monster_zombie_loot = "health_medium"

Definition at line 5 of file zombie.qc.

◆ autocvar_g_monster_zombie_speed_run

float autocvar_g_monster_zombie_speed_run

Definition at line 14 of file zombie.qc.

◆ autocvar_g_monster_zombie_speed_stop

float autocvar_g_monster_zombie_speed_stop

Definition at line 13 of file zombie.qc.

◆ autocvar_g_monster_zombie_speed_walk

float autocvar_g_monster_zombie_speed_walk

Definition at line 15 of file zombie.qc.