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

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (physical_items, Item_Spawn)
void physical_item_damage (entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void physical_item_think (entity this)
void physical_item_touch (entity this, entity toucher)
 REGISTER_MUTATOR (physical_items, autocvar_g_physical_items)

Variables

int autocvar_g_physical_items
float autocvar_g_physical_items_damageforcescale
float autocvar_g_physical_items_reset
vector spawn_angles
vector spawn_origin

Function Documentation

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( physical_items ,
Item_Spawn  )

Definition at line 92 of file sv_physical_items.qc.

93{
94 entity item = M_ARGV(0, entity);
95
96 if(item.owner == NULL && autocvar_g_physical_items <= 1)
97 return;
98 if (item.spawnflags & 1) // floating item
99 return;
100
101 // The actual item can't be physical and trigger at the same time, so make it invisible and use a second entity for physics.
102 // Ugly hack, but unless SOLID_TRIGGER is gotten to work with MOVETYPE_PHYSICS in the engine it can't be fixed.
103 entity wep = spawn();
104 _setmodel(wep, item.model);
105 setsize(wep, item.mins, item.maxs);
106 setorigin(wep, item.origin);
107 wep.angles = item.angles;
108 wep.velocity = item.velocity;
109
110 wep.owner = item;
111 wep.solid = SOLID_CORPSE;
113 wep.takedamage = DAMAGE_AIM;
114 wep.effects |= EF_NOMODELFLAGS; // disable the spinning
115 wep.colormap = item.owner.colormap;
116 wep.glowmod = item.owner.glowmod;
117 wep.damageforcescale = autocvar_g_physical_items_damageforcescale;
118 wep.dphitcontentsmask = item.dphitcontentsmask;
119 wep.cnt = (item.owner != NULL);
120
122 wep.nextthink = time;
124 wep.event_damage = physical_item_damage;
125
126 if(!wep.cnt)
128
129 wep.spawn_origin = wep.origin;
130 wep.spawn_angles = item.angles;
131
132 item.effects |= EF_NODRAW; // hide the original weapon
134 item.aiment = wep; // attach the original weapon
136}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define M_ARGV(x, type)
Definition events.qh:17
const float SOLID_CORPSE
float time
const float EF_NODRAW
#define spawn
float EF_NOMODELFLAGS
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_FOLLOW
Definition movetypes.qh:141
const int MOVETYPE_PHYSICS
Definition movetypes.qh:142
var void func_null()
#define NULL
Definition post.qh:14
#define setSendEntity(e, f)
#define setthink(e, f)
#define settouch(e, f)
Definition self.qh:73
const int DAMAGE_AIM
Definition subs.qh:81
int autocvar_g_physical_items
float autocvar_g_physical_items_damageforcescale
void physical_item_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void physical_item_think(entity this)
void physical_item_touch(entity this, entity toucher)
void DropToFloor_QC_DelayedInit(entity this)
Definition world.qc:2407

References autocvar_g_physical_items, autocvar_g_physical_items_damageforcescale, DAMAGE_AIM, DropToFloor_QC_DelayedInit(), EF_NODRAW, EF_NOMODELFLAGS, entity(), func_null(), M_ARGV, MOVETYPE_FOLLOW, MOVETYPE_PHYSICS, NULL, physical_item_damage(), physical_item_think(), physical_item_touch(), set_movetype(), setSendEntity, setthink, settouch, SOLID_CORPSE, spawn, and time.

◆ physical_item_damage()

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

Definition at line 82 of file sv_physical_items.qc.

83{
84 if(!this.cnt) // not for dropped items
85 if(ITEM_DAMAGE_NEEDKILL(deathtype))
86 {
87 setorigin(this, this.spawn_origin);
88 this.angles = this.spawn_angles;
89 }
90}
float cnt
Definition powerups.qc:24
ent angles
Definition ent_cs.qc:121
#define ITEM_DAMAGE_NEEDKILL(dt)
Definition items.qh:129
vector spawn_origin
vector spawn_angles

References angles, cnt, entity(), ITEM_DAMAGE_NEEDKILL, spawn_angles, spawn_origin, and vector.

Referenced by MUTATOR_HOOKFUNCTION().

◆ physical_item_think()

void physical_item_think ( entity this)

Definition at line 35 of file sv_physical_items.qc.

36{
37 this.nextthink = time;
38
39 this.alpha = this.owner.alpha; // apply fading and ghosting
40
41 if(!this.cnt) // map item, not dropped
42 {
43 // copy ghost item properties
44 this.colormap = this.owner.colormap;
45 this.colormod = this.owner.colormod;
46 this.glowmod = this.owner.glowmod;
47
48 // if the item is not spawned, make sure the invisible / ghost item returns to its origin and stays there
50 {
51 if(this.owner.wait > time) // awaiting respawn
52 {
53 setorigin(this, this.spawn_origin);
54 this.angles = this.spawn_angles;
55 this.solid = SOLID_NOT;
56 this.alpha = -1;
58 }
59 else
60 {
61 this.alpha = 1;
62 this.solid = SOLID_CORPSE;
64 }
65 }
66 }
67
68 if(!this.owner.modelindex)
69 delete(this); // the real item is gone, remove this
70}
vector colormod
Definition powerups.qc:21
float alpha
Definition items.qc:13
entity owner
Definition main.qh:87
const float SOLID_NOT
float nextthink
float colormap
vector glowmod
solid
Definition ent_cs.qc:165
const int MOVETYPE_NONE
Definition movetypes.qh:129
float autocvar_g_physical_items_reset

References alpha, angles, autocvar_g_physical_items_reset, cnt, colormap, colormod, entity(), glowmod, MOVETYPE_NONE, MOVETYPE_PHYSICS, nextthink, owner, set_movetype(), solid, SOLID_CORPSE, SOLID_NOT, spawn_angles, spawn_origin, and time.

Referenced by MUTATOR_HOOKFUNCTION().

◆ physical_item_touch()

void physical_item_touch ( entity this,
entity toucher )

Definition at line 72 of file sv_physical_items.qc.

73{
74 if(!this.cnt) // not for dropped items
76 {
77 setorigin(this, this.spawn_origin);
78 this.angles = this.spawn_angles;
79 }
80}
#define ITEM_TOUCH_NEEDKILL()
Definition items.qh:128

References angles, cnt, entity(), ITEM_TOUCH_NEEDKILL, spawn_angles, spawn_origin, and toucher.

Referenced by MUTATOR_HOOKFUNCTION().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( physical_items ,
autocvar_g_physical_items  )

Definition at line 7 of file sv_physical_items.qc.

8{
9 // check if we have a physics engine
11 {
12 if (!(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")))
13 {
14 LOG_TRACE("Warning: Physical items are enabled but no physics engine can be used. Reverting to old items.");
15 return -1;
16 }
17 }
18
20 {
21 // nothing to roll back
22 }
23
25 {
26 LOG_INFO("This cannot be removed at runtime");
27 return -1;
28 }
29
30 return 0;
31}
#define MUTATOR_ONADD
Definition base.qh:309
#define MUTATOR_ONROLLBACK_OR_REMOVE
Definition base.qh:311
#define MUTATOR_ONREMOVE
Definition base.qh:310
#define LOG_INFO(...)
Definition log.qh:65
#define LOG_TRACE(...)
Definition log.qh:76
float checkextension(string ext)
bool autocvar_physics_ode
Definition movetypes.qh:5

References autocvar_g_physical_items, autocvar_physics_ode, checkextension(), LOG_INFO, LOG_TRACE, MUTATOR_ONADD, MUTATOR_ONREMOVE, and MUTATOR_ONROLLBACK_OR_REMOVE.

Variable Documentation

◆ autocvar_g_physical_items

int autocvar_g_physical_items

Definition at line 3 of file sv_physical_items.qc.

Referenced by MUTATOR_HOOKFUNCTION(), and REGISTER_MUTATOR().

◆ autocvar_g_physical_items_damageforcescale

float autocvar_g_physical_items_damageforcescale

Definition at line 4 of file sv_physical_items.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_physical_items_reset

float autocvar_g_physical_items_reset

Definition at line 5 of file sv_physical_items.qc.

Referenced by physical_item_think().

◆ spawn_angles

vector spawn_angles

◆ spawn_origin

vector spawn_origin