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;
32 own = this.enemy;
33 if (!IS_PLAYER(own))
34 {
35 own = this;
36 this.enemy = NULL; // I still hate you all
37 }
38
39 Damage (toucher, this, own, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, toucher.origin, '0 0 0');
40 }
41 }
42 else if(toucher.damagedbytriggers)
43 {
45 Damage(toucher, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, toucher.origin, '0 0 0');
46 }
47}
48
49/*QUAKED spawnfunc_trigger_hurt (.5 .5 .5) ?
50Any object touching this will be hurt
51set dmg to damage amount
52default dmg = 10000
53*/
57spawnfunc(trigger_hurt)
58{
60 this.active = ACTIVE_ACTIVE;
62 this.use = trigger_hurt_use;
63 this.enemy = world; // I hate you all
64 if (!this.dmg)
65 this.dmg = ((q3compat) ? 5 : 10000);
66 if (this.message == "")
67 this.message = "was in the wrong place";
68 if (this.message2 == "")
69 this.message2 = "was thrown into a world of hurt by";
70 // this.message = "someone like %s always gets wrongplaced";
71
73 trigger_hurt_first = this;
75 trigger_hurt_last.trigger_hurt_next = this;
76 trigger_hurt_last = this;
77}
78
80{
81 entity th;
82
83 for(th = trigger_hurt_first; th; th = th.trigger_hurt_next)
84 if(tracebox_hits_box(start, e_min, e_max, end, th.absmin, th.absmax))
85 return true;
86
87 return false;
88}
89#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:243
float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma)
Definition util.qc:2143
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:503
#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:54
void trigger_hurt_use(entity this, entity actor, entity trigger)
Definition hurt.qc:3
entity trigger_hurt_first
Definition hurt.qc:56
void trigger_hurt_touch(entity this, entity toucher)
Definition hurt.qc:12
entity trigger_hurt_last
Definition hurt.qc:55
float triggerhurttime
Definition hurt.qc:11
bool tracebox_hits_trigger_hurt(vector start, vector e_min, vector e_max, vector end)
Definition hurt.qc:79
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