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