Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
hurt.qc
Go to the documentation of this file.
1#include "hurt.qh"
2#ifdef SVQC
3void trigger_hurt_use(entity this, entity actor, entity trigger)
4{
5 if(IS_PLAYER(actor))
6 this.enemy = actor;
7 else
8 this.enemy = NULL; // let's just destroy it, if taking over is too much work
9}
10
13{
14 if (!toucher.takedamage)
15 return;
16 if (this.active != ACTIVE_ACTIVE)
17 return;
18
19 if(this.team)
20 if(((this.spawnflags & INVERT_TEAMS) == 0) == (this.team != toucher.team))
21 return;
22
23 // only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
24 if (toucher.iscreature)
25 {
26 if (time >= toucher.triggerhurttime + (q3compat && !(this.spawnflags & HURT_SLOW) ? 0.05 : 1))
27 {
29 toucher.triggerhurttime = time;
30
31 entity own = this.enemy;
32 if (!IS_PLAYER(own))
33 {
34 own = this;
35 this.enemy = NULL; // I still hate you all
36 }
37
38 Damage (toucher, this, own, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, toucher.origin, '0 0 0');
39 }
40 }
41 else if(toucher.damagedbytriggers)
42 {
44 Damage(toucher, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, toucher.origin, '0 0 0');
45 }
46}
47
48/*QUAKED spawnfunc_trigger_hurt (.5 .5 .5) ?
49Any object touching this will be hurt
50set dmg to damage amount
51default dmg = 10000
52*/
56spawnfunc(trigger_hurt)
57{
59 this.active = ACTIVE_ACTIVE;
61 this.use = trigger_hurt_use;
62 this.enemy = world; // I hate you all
63 if (!this.dmg)
64 this.dmg = ((q3compat) ? 5 : 10000);
65 if (this.message == "")
66 this.message = "was in the wrong place";
67 if (this.message2 == "")
68 this.message2 = "was thrown into a world of hurt by";
69 // this.message = "someone like %s always gets wrongplaced";
70
72 trigger_hurt_first = this;
74 trigger_hurt_last.trigger_hurt_next = this;
75 trigger_hurt_last = this;
76}
77
79{
80 entity th;
81
82 for(th = trigger_hurt_first; th; th = th.trigger_hurt_next)
83 if(tracebox_hits_box(start, e_min, e_max, end, th.absmin, th.absmax))
84 return true;
85
86 return false;
87}
88#endif
float dmg
Definition breakable.qc:12
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
string message
Definition powerups.qc:19
int team
Definition main.qh:188
int spawnflags
Definition ammo.qh:15
#define IS_PLAYER(s)
Definition player.qh:242
float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma)
Definition util.qc:2239
float time
#define use
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
const int INVERT_TEAMS
Definition defs.qh:10
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
entity trigger_hurt_next
Definition hurt.qc:53
void trigger_hurt_use(entity this, entity actor, entity trigger)
Definition hurt.qc:3
entity trigger_hurt_first
Definition hurt.qc:55
void trigger_hurt_touch(entity this, entity toucher)
Definition hurt.qc:12
entity trigger_hurt_last
Definition hurt.qc:54
float triggerhurttime
Definition hurt.qc:11
bool tracebox_hits_trigger_hurt(vector start, vector e_min, vector e_max, vector end)
Definition hurt.qc:78
const int HURT_SLOW
Definition hurt.qh:4
#define EXACTTRIGGER_TOUCH(e, t)
Definition common.qh:115
#define EXACTTRIGGER_INIT
Definition common.qh:116
#define NULL
Definition post.qh:14
#define world
Definition post.qh:15
q3compat
Definition quake3.qc:59
vector
Definition self.qh:92
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
#define spawnfunc(id)
Definition spawnfunc.qh:96
entity enemy
Definition sv_ctf.qh:153
string message2
Definition triggers.qh:19