tmax_y = tmin_y + 1;
}
- setsize (trigger, tmin, tmax);
+ if(tmin_x > tmax_x)
+ if(tmin_y > tmax_y)
+ if(tmin_z > tmax_z)
+ {
+ setsize (trigger, tmin, tmax);
+ return;
+ }
+
+ // otherwise, something is fishy...
+ remove(trigger);
+ objerror("plat_spawn_inside_trigger: platform has odd size or lip, can't spawn");
}
void plat_hit_top()
void spawnfunc_path_corner() { }
void spawnfunc_func_plat()
{
- if (!self.t_length)
- self.t_length = 80;
- if (!self.t_width)
- self.t_width = 10;
-
if (self.sounds == 0)
self.sounds = 2;
if (!self.speed)
self.speed = 150;
+ if (!self.lip)
+ self.lip = 16;
+ if (!self.height)
+ self.height = self.size_z - self.lip;
self.pos1 = self.origin;
self.pos2 = self.origin;
- self.pos2_z = self.origin_z - self.size_z + 8;
-
- plat_spawn_inside_trigger (); // the "start moving" trigger
+ self.pos2_z = self.origin_z - self.height;
self.reset = plat_reset;
plat_reset();
+
+ plat_spawn_inside_trigger (); // the "start moving" trigger
}
else
door = self;
- if (door.spawnflags & (SPAWNFLAGS_GOLD_KEY | SPAWNFLAGS_SILVER_KEY)) {
- // this door require a key
- // only a player can have a key
- if (other.classname != "player")
- return FALSE;
-
- // check gold key
- if (self.owner.spawnflags & SPAWNFLAGS_GOLD_KEY) {
- if (!(other.itemkeys & KEYS_GOLD_KEY)) {
- if (other.key_door_messagetime <= time) {
- play2(other, "misc/talk.wav");
- centerprint(other, "You don't have the gold key!");
- other.key_door_messagetime = time + 2;
- }
- return FALSE;
- } else {
- self.owner.spawnflags &~= SPAWNFLAGS_GOLD_KEY;
- }
+ // no key needed
+ if not(door.itemkeys)
+ return TRUE;
+
+ // this door require a key
+ // only a player can have a key
+ if (other.classname != "player")
+ return FALSE;
+
+ if (item_keys_usekey(door, other)) {
+ // some keys were used
+ if (other.key_door_messagetime <= time) {
+ play2(other, "misc/talk.wav");
+ centerprint(other, strcat("You also need ", item_keys_keylist(door.itemkeys), "!"));
+ other.key_door_messagetime = time + 2;
}
-
- // check silver key
- if (self.owner.spawnflags & SPAWNFLAGS_SILVER_KEY) {
- if (!(other.itemkeys & KEYS_SILVER_KEY)) {
- if (other.key_door_messagetime <= time) {
- play2(other, "misc/talk.wav");
- centerprint(other, "You don't have the silver key!");
- other.key_door_messagetime = time + 2;
- }
- return FALSE;
- } else {
- self.owner.spawnflags &~= SPAWNFLAGS_SILVER_KEY;
- }
+ } else {
+ // no keys were used
+ if (other.key_door_messagetime <= time) {
+ play2(other, "misc/talk.wav");
+ centerprint(other, strcat("You need ", item_keys_keylist(door.itemkeys), "!"));
+ other.key_door_messagetime = time + 2;
}
-
+ }
+
+ if (door.itemkeys) {
// door is now unlocked
play2(other, "misc/talk.wav");
centerprint(other, "Door unlocked!");
- }
-
- return TRUE;
+ return TRUE;
+ } else
+ return FALSE;
}
return;
self.health = self.health - damage;
- if (self.spawnflags & SPAWNFLAGS_GOLD_KEY || self.spawnflags & SPAWNFLAGS_SILVER_KEY) {
+ if (self.itemkeys) {
// don't allow opening doors through damage if keys are required
return;
}
self.think = SUB_Null;
}
+// spawnflags require key (for now only func_door)
+#define SPAWNFLAGS_GOLD_KEY 8
+#define SPAWNFLAGS_SILVER_KEY 16
void spawnfunc_func_door()
{
- //dprint("spawnfunc_func_door() spawnflags=", ftos(self.spawnflags));
- //dprint(", gold_key=", ftos(self.spawnflags & SPAWNFLAGS_GOLD_KEY));
- //dprint(", silver_key=", ftos(self.spawnflags & SPAWNFLAGS_SILVER_KEY), "\n");
-
+ // Quake 1 keys compatibility
+ if (self.spawnflags & SPAWNFLAGS_GOLD_KEY)
+ self.itemkeys |= ITEM_KEY_BIT(0);
+ if (self.spawnflags & SPAWNFLAGS_SILVER_KEY)
+ self.itemkeys |= ITEM_KEY_BIT(1);
+
//if (!self.deathtype) // map makers can override this
// self.deathtype = " got in the way";
SetMovedir ();
InitializeEntity(self, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
}
+
+void conveyor_think()
+{
+ entity e;
+
+ // set myself as current conveyor where possible
+ for(e = world; (e = findentity(e, conveyor, self)); )
+ e.conveyor = world;
+
+ if(self.state)
+ {
+ for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5); e; e = e.chain)
+ if(!e.conveyor.state)
+ if(isPushable(e))
+ {
+ vector emin = e.absmin;
+ vector emax = e.absmax;
+ if(self.solid == SOLID_BSP)
+ {
+ emin -= '1 1 1';
+ emax += '1 1 1';
+ }
+ if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
+ if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
+ e.conveyor = self;
+ }
+
+ for(e = world; (e = findentity(e, conveyor, self)); )
+ {
+ if(e.flags & FL_CLIENT) // doing it via velocity has quite some advantages
+ continue; // done in SV_PlayerPhysics
+
+ setorigin(e, e.origin + self.movedir * sys_frametime);
+ move_out_of_solid(e);
+ UpdateCSQCProjectile(e);
+ /*
+ // stupid conveyor code
+ tracebox(e.origin, e.mins, e.maxs, e.origin + self.movedir * sys_frametime, MOVE_NORMAL, e);
+ if(trace_fraction > 0)
+ setorigin(e, trace_endpos);
+ */
+ }
+ }
+
+ self.nextthink = time;
+}
+
+void conveyor_use()
+{
+ self.state = !self.state;
+}
+
+void conveyor_reset()
+{
+ self.state = (self.spawnflags & 1);
+}
+
+void conveyor_init()
+{
+ if (!self.speed)
+ self.speed = 200;
+ self.movedir = self.movedir * self.speed;
+ self.think = conveyor_think;
+ self.nextthink = time;
+ IFTARGETED
+ {
+ self.use = conveyor_use;
+ self.reset = conveyor_reset;
+ conveyor_reset();
+ }
+ else
+ self.state = 1;
+}
+
+void spawnfunc_trigger_conveyor()
+{
+ SetMovedir();
+ EXACTTRIGGER_INIT;
+ conveyor_init();
+}
+
+void spawnfunc_func_conveyor()
+{
+ SetMovedir();
+ InitMovingBrushTrigger();
+ self.movetype = MOVETYPE_NONE;
+ conveyor_init();
+}