#ifdef SVQC
-void conveyor_setactive(entity this, int act)
-{
- int old_status = this.active;
- if(act == ACTIVE_TOGGLE)
- {
- if(this.active == ACTIVE_ACTIVE)
- {
- this.active = ACTIVE_NOT;
- }
- else
- {
- this.active = ACTIVE_ACTIVE;
- }
- }
- else
- {
- this.active = act;
- }
-
- if (this.active != old_status)
- {
- this.SendFlags |= SF_TRIGGER_UPDATE;
- }
-}
-
-// Compatibility with old maps
-void conveyor_use(entity this, entity actor, entity trigger)
-{
- conveyor_setactive(this, ACTIVE_TOGGLE);
-}
-
-void conveyor_reset(entity this)
-{
- IFTARGETED
- {
- if(this.spawnflags & CONVEYOR_START_ENABLED)
- {
- this.active = ACTIVE_ACTIVE;
- }
- }
- else
- {
- this.active = ACTIVE_ACTIVE;
- }
-
- this.SendFlags |= SF_TRIGGER_UPDATE;
-}
-
bool conveyor_send(entity this, entity to, int sendflags)
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
this.movedir *= this.speed;
setthink(this, conveyor_think);
this.nextthink = time;
- this.setactive = conveyor_setactive;
+ this.setactive = generic_netlinked_setactive;
IFTARGETED
{
// backwards compatibility
- this.use = conveyor_use;
+ this.use = generic_netlinked_legacy_use;
}
- this.reset = conveyor_reset;
+ this.reset = generic_netlinked_reset;
this.reset(this);
FixSize(this);
#ifdef SVQC
// NOTE: also contains func_sparks
-bool pointparticles_SendEntity(entity this, entity to, float fl)
+bool pointparticles_SendEntity(entity this, entity to, float sendflags)
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_POINTPARTICLES);
// optional features to save space
- fl = fl & 0x0F;
- if(this.spawnflags & 2)
- fl |= 0x10; // absolute count on toggle-on
+ sendflags = sendflags & 0x0F;
+ if(this.spawnflags & PARTICLES_IMPULSE)
+ sendflags |= SF_POINTPARTICLES_IMPULSE; // absolute count on toggle-on
if(this.movedir != '0 0 0' || this.velocity != '0 0 0')
- fl |= 0x20; // 4 bytes - saves CPU
+ sendflags |= SF_POINTPARTICLES_MOVING; // 4 bytes - saves CPU
if(this.waterlevel || this.count != 1)
- fl |= 0x40; // 4 bytes - obscure features almost never used
+ sendflags |= SF_POINTPARTICLES_JITTER_AND_COUNT; // 4 bytes - obscure features almost never used
if(this.mins != '0 0 0' || this.maxs != '0 0 0')
- fl |= 0x80; // 14 bytes - saves lots of space
+ sendflags |= SF_POINTPARTICLES_BOUNDS; // 14 bytes - saves lots of space
- WriteByte(MSG_ENTITY, fl);
- if(fl & 2)
+ WriteByte(MSG_ENTITY, sendflags);
+ if(sendflags & SF_TRIGGER_UPDATE)
{
- if(this.state)
+ if(this.active == ACTIVE_ACTIVE)
WriteCoord(MSG_ENTITY, this.impulse);
else
WriteCoord(MSG_ENTITY, 0); // off
}
- if(fl & 4)
+ if(sendflags & SF_TRIGGER_RESET)
{
WriteVector(MSG_ENTITY, this.origin);
}
- if(fl & 1)
+ if(sendflags & SF_TRIGGER_INIT)
{
if(this.model != "null")
{
WriteShort(MSG_ENTITY, this.modelindex);
- if(fl & 0x80)
+ if(sendflags & SF_POINTPARTICLES_BOUNDS)
{
WriteVector(MSG_ENTITY, this.mins);
WriteVector(MSG_ENTITY, this.maxs);
else
{
WriteShort(MSG_ENTITY, 0);
- if(fl & 0x80)
+ if(sendflags & SF_POINTPARTICLES_BOUNDS)
{
WriteVector(MSG_ENTITY, this.maxs);
}
}
WriteShort(MSG_ENTITY, this.cnt);
WriteString(MSG_ENTITY, this.mdl);
- if(fl & 0x20)
+ if(sendflags & SF_POINTPARTICLES_MOVING)
{
WriteShort(MSG_ENTITY, compressShortVector(this.velocity));
WriteShort(MSG_ENTITY, compressShortVector(this.movedir));
}
- if(fl & 0x40)
+ if(sendflags & SF_POINTPARTICLES_JITTER_AND_COUNT)
{
WriteShort(MSG_ENTITY, this.waterlevel * 16.0);
WriteByte(MSG_ENTITY, this.count * 16.0);
return 1;
}
-void pointparticles_use(entity this, entity actor, entity trigger)
-{
- this.state = !this.state;
- this.SendFlags |= 2;
-}
-
void pointparticles_think(entity this)
{
if(this.origin != this.oldorigin)
{
- this.SendFlags |= 4;
+ this.SendFlags |= SF_TRIGGER_RESET;
this.oldorigin = this.origin;
}
this.nextthink = time;
}
-void pointparticles_reset(entity this)
-{
- if(this.spawnflags & 1)
- this.state = 1;
- else
- this.state = 0;
-}
-
spawnfunc(func_pointparticles)
{
if(this.model != "") { precache_model(this.model); _setmodel(this, this.model); }
setsize(this, '0 0 0', this.maxs - this.mins);
}
//if(!this.cnt) this.cnt = _particleeffectnum(this.mdl);
+ this.setactive = generic_netlinked_setactive;
- Net_LinkEntity(this, (this.spawnflags & 4), 0, pointparticles_SendEntity);
+ Net_LinkEntity(this, (this.spawnflags & PARTICLES_VISCULLING), 0, pointparticles_SendEntity);
IFTARGETED
{
- this.use = pointparticles_use;
- this.reset = pointparticles_reset;
- this.reset(this);
+ // backwards compatibility
+ this.use = generic_netlinked_legacy_use;
}
- else
- this.state = 1;
+ this.reset = generic_netlinked_reset;
+ this.reset(this);
setthink(this, pointparticles_think);
this.nextthink = time;
}
class(PointParticles) .string noise; // sound
class(PointParticles) .float atten;
class(PointParticles) .float volume;
-class(PointParticles) .float absolute; // 1 = count per second is absolute, 2 = only spawn at toggle
+class(PointParticles) .int absolute; // 1 = count per second is absolute, ABSOLUTE_ONLY_SPAWN_AT_TOGGLE = only spawn at toggle
class(PointParticles) .vector movedir; // trace direction
class(PointParticles) .float glow_color; // palette index
+const int ABSOLUTE_ONLY_SPAWN_AT_TOGGLE = 2;
+
void Draw_PointParticles(entity this)
{
float n, i, fail;
o = this.origin;
sz = this.maxs - this.mins;
n = doBGMScript(this);
- if(this.absolute == 2)
+ if(this.absolute == ABSOLUTE_ONLY_SPAWN_AT_TOGGLE)
{
if(n >= 0)
n = this.just_toggled ? this.impulse : 0;
{
float i;
vector v;
- int f = ReadByte();
- if(f & 2)
+ int sendflags = ReadByte();
+ if(sendflags & SF_TRIGGER_UPDATE)
{
i = ReadCoord(); // density (<0: point, >0: volume)
if(i && !this.impulse && (this.cnt || this.mdl)) // this.cnt check is so it only happens if the ent already existed
this.just_toggled = 1;
this.impulse = i;
}
- if(f & 4)
+ if(sendflags & SF_TRIGGER_RESET)
{
this.origin = ReadVector();
}
- if(f & 1)
+ if(sendflags & SF_TRIGGER_INIT)
{
this.modelindex = ReadShort();
- if(f & 0x80)
+ if(sendflags & SF_POINTPARTICLES_BOUNDS)
{
if(this.modelindex)
{
this.cnt = ReadShort(); // effect number
this.mdl = strzone(ReadString()); // effect string
- if(f & 0x20)
+ if(sendflags & SF_POINTPARTICLES_MOVING)
{
this.velocity = decompressShortVector(ReadShort());
this.movedir = decompressShortVector(ReadShort());
{
this.velocity = this.movedir = '0 0 0';
}
- if(f & 0x40)
+ if(sendflags & SF_POINTPARTICLES_JITTER_AND_COUNT)
{
this.waterlevel = ReadShort() / 16.0;
this.count = ReadByte() / 16.0;
return = true;
- if(f & 2)
+ if(sendflags & SF_TRIGGER_UPDATE)
{
this.absolute = (this.impulse >= 0);
if(!this.absolute)
{
v = this.maxs - this.mins;
- this.impulse *= -v.x * v.y * v.z / 262144; // relative: particles per 64^3 cube
+ this.impulse *= -v.x * v.y * v.z / (64**3); // relative: particles per 64^3 cube
}
}
- if(f & 0x10)
- this.absolute = 2;
+ if(sendflags & SF_POINTPARTICLES_IMPULSE)
+ this.absolute = ABSOLUTE_ONLY_SPAWN_AT_TOGGLE;
setorigin(this, this.origin);
setsize(this, this.mins, this.maxs);
// generic usage
const int NOSPLASH = BIT(8); // generic anti-splashdamage spawnflag
+const int START_ENABLED = BIT(0);
// bobbing
const int BOBBING_XAXIS = BIT(0);
// button
const int BUTTON_DONTACCUMULATEDMG = BIT(7);
-// conveyor
-const int CONVEYOR_START_ENABLED = BIT(0);
-
// door, door_rotating and door_secret
const int DOOR_START_OPEN = BIT(0);
const int DOOR_DONT_LINK = BIT(2);
const int DOOR_SECRET_NO_SHOOT = BIT(3); // only opened by trigger
const int DOOR_SECRET_YES_SHOOT = BIT(4); // shootable even if targeted
+// particles
+const int PARTICLES_IMPULSE = BIT(1);
+const int PARTICLES_VISCULLING = BIT(2);
+
// jumppads
const int PUSH_ONCE = BIT(0);
const int PUSH_SILENT = BIT(1); // not used?
const int TELEPORT_FLAG_FORCE_TDEATH = BIT(3);
// triggers
+const int SPAWNFLAG_NOMESSAGE = BIT(0);
+const int SPAWNFLAG_NOTOUCH = BIT(0); // why are these the same?
+
+//----------
+// SENDFLAGS
+//----------
const int SF_TRIGGER_INIT = BIT(0);
const int SF_TRIGGER_UPDATE = BIT(1);
const int SF_TRIGGER_RESET = BIT(2);
-const int SPAWNFLAG_NOMESSAGE = BIT(0);
-const int SPAWNFLAG_NOTOUCH = BIT(0); // why are these the same?
+// pointparticles
+const int SF_POINTPARTICLES_IMPULSE = BIT(4);
+const int SF_POINTPARTICLES_MOVING = BIT(5); // Send velocity and movedir
+const int SF_POINTPARTICLES_JITTER_AND_COUNT = BIT(6); // Send waterlevel (=jitter) and count
+const int SF_POINTPARTICLES_BOUNDS = BIT(7); // Send min and max of the brush