Cleanse the touch functions of the other evil
[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, entity toucher)
4 {
5 #ifdef SVQC
6         if (!toucher.iscreature)
7                 return;
8         if(IS_VEHICLE(toucher))
9                 return;
10 #elif defined(CSQC)
11         if(!toucher.isplayermodel)
12                 return;
13 #endif
14
15         EXACTTRIGGER_TOUCH(this, toucher);
16
17         toucher.ladder_time = time + 0.1;
18         toucher.ladder_entity = this;
19 }
20
21 #ifdef SVQC
22 bool func_ladder_send(entity this, entity to, int sf)
23 {
24         WriteHeader(MSG_ENTITY, ENT_CLIENT_LADDER);
25
26         WriteString(MSG_ENTITY, this.classname);
27         WriteByte(MSG_ENTITY, this.skin);
28         WriteCoord(MSG_ENTITY, this.speed);
29
30         trigger_common_write(this, false);
31
32         return true;
33 }
34
35 void func_ladder_link(entity this)
36 {
37         trigger_link(this, func_ladder_send);
38         //this.model = "null";
39 }
40
41 void func_ladder_init(entity this)
42 {
43         settouch(this, func_ladder_touch);
44
45         trigger_init(this);
46         func_ladder_link(this);
47 }
48
49 spawnfunc(func_ladder)
50 {
51         func_ladder_init(this);
52 }
53
54 spawnfunc(func_water)
55 {
56         func_ladder_init(this);
57 }
58
59 #elif defined(CSQC)
60 .float speed;
61
62 void func_ladder_remove(entity this)
63 {
64         if(this.classname) { strunzone(this.classname); }
65         this.classname = string_null;
66 }
67
68 NET_HANDLE(ENT_CLIENT_LADDER, bool isnew)
69 {
70         this.classname = strzone(ReadString());
71         this.skin = ReadByte();
72         this.speed = ReadCoord();
73
74         trigger_common_read(this, false);
75
76         this.solid = SOLID_TRIGGER;
77         settouch(this, func_ladder_touch);
78         this.drawmask = MASK_NORMAL;
79         this.move_time = time;
80         this.entremove = func_ladder_remove;
81
82         return true;
83 }
84 #endif