]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Link ladders (landing on them is rough, unfixable currently)
authorMario <mario@smbclan.net>
Tue, 1 Dec 2015 15:43:49 +0000 (01:43 +1000)
committerMario <mario@smbclan.net>
Tue, 1 Dec 2015 15:43:49 +0000 (01:43 +1000)
qcsrc/common/triggers/func/ladder.qc
qcsrc/common/triggers/trigger/swamp.qc

index 0ddf08eef07cb0585143f276a06c8b5fb139ce0f..df4cb4453f3254ee4654e263fc2441a6a1556324 100644 (file)
@@ -8,10 +8,6 @@ void func_ladder_touch()
        if(IS_VEHICLE(other))
                return;
 #endif
-#ifdef CSQC
-       if(other.classname != "csqcmodel")
-               return;
-#endif
 
        EXACTTRIGGER_TOUCH;
 
@@ -20,14 +16,37 @@ void func_ladder_touch()
 }
 
 #ifdef SVQC
-bool func_ladder_send(entity this, entity to, float sf)
-{
+bool func_ladder_send(entity to, int sf)
+{SELFPARAM();
        WriteHeader(MSG_ENTITY, ENT_CLIENT_LADDER);
 
+       int f = 0;
+       if(self.warpzone_isboxy)
+               BITSET_ASSIGN(f, 1);
+       if(self.origin != '0 0 0')
+               BITSET_ASSIGN(f, 4);
+       WriteByte(MSG_ENTITY, f);
+
+       // we need THESE to render the warpzone (and cull properly)...
+       if(f & 4)
+       {
+               WriteCoord(MSG_ENTITY, self.origin.x);
+               WriteCoord(MSG_ENTITY, self.origin.y);
+               WriteCoord(MSG_ENTITY, self.origin.z);
+       }
+
+       WriteShort(MSG_ENTITY, self.modelindex);
+       WriteCoord(MSG_ENTITY, self.mins.x);
+       WriteCoord(MSG_ENTITY, self.mins.y);
+       WriteCoord(MSG_ENTITY, self.mins.z);
+       WriteCoord(MSG_ENTITY, self.maxs.x);
+       WriteCoord(MSG_ENTITY, self.maxs.y);
+       WriteCoord(MSG_ENTITY, self.maxs.z);
+       WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
+
        WriteString(MSG_ENTITY, self.classname);
        WriteByte(MSG_ENTITY, self.skin);
-       WriteByte(MSG_ENTITY, self.speed);
-       WriteString(MSG_ENTITY, self.mdl);
+       WriteCoord(MSG_ENTITY, self.speed);
 
        trigger_common_write(false);
 
@@ -36,53 +55,83 @@ bool func_ladder_send(entity this, entity to, float sf)
 
 void func_ladder_link()
 {
-       //self.SendEntity = func_ladder_send;
-       //self.SendFlags = 0xFFFFFF;
+       self.SendEntity = func_ladder_send;
+       self.SendFlags = 0xFFFFFF;
        //self.model = "null";
 }
 
-spawnfunc(func_ladder)
+void func_ladder_init()
 {
-       self.mdl = self.model;
-       EXACTTRIGGER_INIT;
+       //self.mdl = self.model;
+       string m = self.model;
+       WarpZoneLib_ExactTrigger_Init();
+       if(m != "")
+       {
+               precache_model(m);
+               _setmodel(self, m); // no precision needed
+       }
+       setorigin(self, self.origin);
+       if(self.scale)
+               setsize(self, self.mins * self.scale, self.maxs * self.scale);
+       else
+               setsize(self, self.mins, self.maxs);
        self.touch = func_ladder_touch;
 
        func_ladder_link();
 }
 
-spawnfunc(func_water)
+spawnfunc(func_ladder)
 {
-       self.mdl = self.model;
-       EXACTTRIGGER_INIT;
-       self.touch = func_ladder_touch;
+       func_ladder_init();
+}
 
-       func_ladder_link();
+spawnfunc(func_water)
+{
+       func_ladder_init();
 }
 
 #elif defined(CSQC)
 .float speed;
 
+void func_ladder_remove()
+{
+       if(self.classname) { strunzone(self.classname); }
+       self.classname = string_null;
+}
+
 NET_HANDLE(ENT_CLIENT_LADDER, bool isnew)
 {
+       int f = ReadByte();
+       self.warpzone_isboxy = (f & 1);
+       if(f & 4)
+       {
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+       }
+       else
+               self.origin = '0 0 0';
+
+       self.modelindex = ReadShort();
+       self.mins_x = ReadCoord();
+       self.mins_y = ReadCoord();
+       self.mins_z = ReadCoord();
+       self.maxs_x = ReadCoord();
+       self.maxs_y = ReadCoord();
+       self.maxs_z = ReadCoord();
+       self.scale = ReadByte() / 16;
        self.classname = strzone(ReadString());
        self.skin = ReadByte();
-       self.speed = ReadByte();
-       self.model = strzone(ReadString());
+       self.speed = ReadCoord();
 
        trigger_common_read(false);
 
-       return = true;
-
-       self.mins = self.maxs = '0 0 0';
-
        self.solid = SOLID_TRIGGER;
-       self.draw = trigger_draw_generic;
-       self.trigger_touch = func_ladder_touch;
+       self.move_touch = func_ladder_touch;
        self.drawmask = MASK_NORMAL;
        self.move_time = time;
-       self.entremove = trigger_remove_generic;
+       self.entremove = func_ladder_remove;
 
-       //precache_model(self.mdl);
-       EXACTTRIGGER_INIT;
+       return true;
 }
 #endif
index 535bddbc1a8c36b9ec21319ed70dff665993c4c1..768a3c78b9a94ffccd33b06c01b78d5181dcd4f8 100644 (file)
@@ -95,8 +95,8 @@ void swamp_touch()
 REGISTER_NET_LINKED(ENT_CLIENT_SWAMP)
 
 #ifdef SVQC
-float swamp_send(entity to, float sf)
-{SELFPARAM();
+float swamp_send(entity this, entity to, float sf)
+{
        WriteHeader(MSG_ENTITY, ENT_CLIENT_SWAMP);
 
        WriteByte(MSG_ENTITY, self.dmg); // can probably get away with using a single byte here
@@ -110,7 +110,7 @@ float swamp_send(entity to, float sf)
 
 void swamp_link()
 {SELFPARAM();
-       Net_LinkEntity(self, false, 0, func_ladder_send);
+       Net_LinkEntity(self, false, 0, swamp_send);
 }
 
 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?