]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/ladder.qc
Merge branch 'TimePath/killself' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / ladder.qc
1 REGISTER_NET_LINKED(ENT_CLIENT_LADDER)
2
3 void func_ladder_touch(entity this)
4 {
5 #ifdef SVQC
6         if (!other.iscreature)
7                 return;
8         if(IS_VEHICLE(other))
9                 return;
10 #elif defined(CSQC)
11         if(!other.isplayermodel)
12                 return;
13 #endif
14
15         EXACTTRIGGER_TOUCH;
16
17         other.ladder_time = time + 0.1;
18         other.ladder_entity = self;
19 }
20
21 #ifdef SVQC
22 bool func_ladder_send(entity to, int sf)
23 {SELFPARAM();
24         WriteHeader(MSG_ENTITY, ENT_CLIENT_LADDER);
25
26         WriteString(MSG_ENTITY, self.classname);
27         WriteByte(MSG_ENTITY, self.skin);
28         WriteCoord(MSG_ENTITY, self.speed);
29
30         trigger_common_write(self, false);
31
32         return true;
33 }
34
35 void func_ladder_link(entity this)
36 {
37         this.SendEntity = func_ladder_send;
38         this.SendFlags = 0xFFFFFF;
39         //this.model = "null";
40 }
41
42 void func_ladder_init(entity this)
43 {
44         settouch(this, func_ladder_touch);
45
46         trigger_init(this);
47         func_ladder_link(this);
48 }
49
50 spawnfunc(func_ladder)
51 {
52         func_ladder_init(this);
53 }
54
55 spawnfunc(func_water)
56 {
57         func_ladder_init(this);
58 }
59
60 #elif defined(CSQC)
61 .float speed;
62
63 void func_ladder_remove(entity this)
64 {
65         if(this.classname) { strunzone(this.classname); }
66         this.classname = string_null;
67 }
68
69 NET_HANDLE(ENT_CLIENT_LADDER, bool isnew)
70 {
71         this.classname = strzone(ReadString());
72         this.skin = ReadByte();
73         this.speed = ReadCoord();
74
75         trigger_common_read(this, false);
76
77         this.solid = SOLID_TRIGGER;
78         settouch(this, func_ladder_touch);
79         this.drawmask = MASK_NORMAL;
80         this.move_time = time;
81         this.entremove = func_ladder_remove;
82
83         return true;
84 }
85 #endif