-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.qc
142 lines (114 loc) · 3.21 KB
/
client.qc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
void() Chasecam_Update;
void() ClientKill;
void() ClientConnect;
void() ClientDisconnect;
void() PlayerPreThink;
void() PlayerPostThink;
void() PlayerDeathThink;
void() respawn;
void() PutClientInServer;
void() ClientKill =
{
bprint (self.netname);
bprint (" suicides\n");
self.frags = self.frags - 2;
respawn();
};
void() PlayerDeathThink =
{
if (self.deadflag == DEAD_DEAD)
{
if (self.button2 || self.button1 || self.button0)
return;
self.deadflag = DEAD_RESPAWNABLE;
return;
}
if (!self.button2 && !self.button1 && !self.button0)
return;
self.button0 = 0;
self.button1 = 0;
self.button2 = 0;
respawn();
self.deadflag = 0; // bug fix
};
void() respawn =
{
if (coop || deathmatch)
{
PutClientInServer();
}
else
{
localcmd ("restart\n");
}
};
void() PlayerPreThink =
{
CheckImpulses();
Chasecam_Update();
SetClientFrame ();
WaterMove ();
if (self.deadflag >= DEAD_DEAD)
{
PlayerDeathThink ();
return;
}
if (self.deadflag == DEAD_DYING)
return; // dying so do nothing
if (self.button2)
{
PlayerJump ();
}
};
void() PutClientInServer =
{
local entity spawn_spot; // This holds where we want to spawn
spawn_spot = find (world, classname, "info_player_start"); // Find it
self.classname = "player"; // I'm a player
self.health = self.max_health = 100; // My health and my max is 100
self.takedamage = DAMAGE_AIM; // I can be fired at
self.solid = SOLID_SLIDEBOX; // Things sort of 'slide' past me
self.movetype = MOVETYPE_WALK; // Yes I want to walk
self.flags = FL_CLIENT; // Yes, I'm a client
self.th_die = PlayerDie;
self.th_pain = PlayerPain;
self.origin = spawn_spot.origin + '0 0 1'; // Move to the spawnspot location
self.angles = spawn_spot.angles; // Face the angle the spawnspot indicates
self.fixangle = TRUE; // Turn this way immediately
setmodel (self, "progs/player.mdl"); // Set player model
setsize (self, VEC_HULL_MIN, VEC_HULL_MAX); // Set my size
self.view_ofs = '0 0 22'; // Center my view
self.velocity = '0 0 0'; // Stop any old movement
};
void() ClientConnect =
{
bprint (self.netname);
bprint (" entered the game\n");
};
void() ClientDisconnect =
{
bprint (self.netname);
bprint (" left the game with ");
bprint (ftos(self.frags));
bprint (" frags\n");
sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
};
void() PlayerPostThink =
{
if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) && (self.health > 0))
{
if (self.watertype == CONTENT_WATER)
sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
else if (self.jump_flag < -650)
{
T_Damage (self, world, world, 5);
sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
self.deathtype = "falling";
}
else
sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
self.jump_flag = 0;
}
if (!(self.flags & FL_ONGROUND))
self.jump_flag = self.velocity_z;
};