ew-progs/player.qc

526 lines
13 KiB
C++
Raw Normal View History

2011-09-06 00:00:00 +00:00
void() bubble_bob;
/*
==============================================================================
PLAYER
==============================================================================
*/
$cd id1/models/player_4
$origin 0 -6 24
$base base
$skin skin
//Won't be using this anymore
//
// running
//
$frame axrun1 axrun2 axrun3 axrun4 axrun5 axrun6
$frame rockrun1 rockrun2 rockrun3 rockrun4 rockrun5 rockrun6
//
// standing
//
$frame stand1 stand2 stand3 stand4 stand5
$frame axstnd1 axstnd2 axstnd3 axstnd4 axstnd5 axstnd6
$frame axstnd7 axstnd8 axstnd9 axstnd10 axstnd11 axstnd12
//
// pain
//
$frame axpain1 axpain2 axpain3 axpain4 axpain5 axpain6
$frame pain1 pain2 pain3 pain4 pain5 pain6
//
// death
//
$frame axdeth1 axdeth2 axdeth3 axdeth4 axdeth5 axdeth6
$frame axdeth7 axdeth8 axdeth9
$frame deatha1 deatha2 deatha3 deatha4 deatha5 deatha6 deatha7 deatha8
$frame deatha9 deatha10 deatha11
$frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8
$frame deathb9
$frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8
$frame deathc9 deathc10 deathc11 deathc12 deathc13 deathc14 deathc15
$frame deathd1 deathd2 deathd3 deathd4 deathd5 deathd6 deathd7
$frame deathd8 deathd9
$frame deathe1 deathe2 deathe3 deathe4 deathe5 deathe6 deathe7
$frame deathe8 deathe9
//
// attacks
//
$frame nailatt1 nailatt2
$frame light1 light2
$frame rockatt1 rockatt2 rockatt3 rockatt4 rockatt5 rockatt6
$frame shotatt1 shotatt2 shotatt3 shotatt4 shotatt5 shotatt6
$frame axatt1 axatt2 axatt3 axatt4 axatt5 axatt6
$frame axattb1 axattb2 axattb3 axattb4 axattb5 axattb6
$frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6
$frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6
/*
==============================================================================
PLAYER
==============================================================================
*/
void() player_run;
void() player_stand1 =[ 0, player_stand1 ]
{
if (self.classname == "observer") //koolio, don't allow observers
return;
if (self.weapon == IT_DAGGER || self.weapon == IT_SMITE) //Fixme: This should probably be done in a neater way
self.weaponframe=5;
else if (self.weapon == IT_CROSSBOW)
self.weaponframe = 4;
else if (self.weapon == IT_SWORD) //Sword
self.weaponframe = 7;
else
self.weaponframe=0;
if (self.velocity_x || self.velocity_y)
{
self.walkframe=74;
player_run();
return;
}
if (self.walkframe >= 73)
self.walkframe = 0;
self.frame = 0 + self.walkframe;
self.walkframe = self.walkframe + 1;
};
void() FootSteps =
{
if (self.walkframe == 75 || self.walkframe == 78)
{
if (self.velocity)
{
{
if (self.flags & FL_ONGROUND)
{
if (self.waterlevel == 0)
{
local float rand0m;
rand0m = random()*4;
if (rand0m <= 3)
{
sound (self, CHAN_AUTO, "player/foot1.wav", 0.5, ATTN_NORM);
//centerprint(self, "walkin' on rand0m 3");
}
else if (rand0m <= 2)
{
sound (self, CHAN_AUTO, "player/foot2.wav", 0.5, ATTN_NORM);
//centerprint(self, "walkin' on rand0m 2");
}
else if (rand0m <= 1)
sound (self, CHAN_AUTO, "player/foot3.wav", 0.5, ATTN_NORM);
else
sound (self, CHAN_AUTO, "player/foot4.wav", 0.5, ATTN_NORM);
}
}
}
}
}
};
void() player_run =[ 74, player_run ]
{
if (self.classname == "observer") //koolio, don't allow observers
return;
FootSteps();
if (self.weapon == IT_DAGGER || self.weapon == IT_SMITE) //Fixme: This should probably be done in a neater way
self.weaponframe=5;
else if (self.weapon == IT_CROSSBOW)
self.weaponframe = 4;
else if (self.weapon == IT_SWORD) //Sword
self.weaponframe = 7;
else
self.weaponframe=0;
if (!self.velocity_x && !self.velocity_y)
{
self.walkframe=0;
player_stand1();
return;
}
if (self.walkframe >= 5)
self.walkframe = 0;
self.frame = self.frame + self.walkframe;
self.walkframe = self.walkframe + 1;
};
//============================================================================
void(float num_bubbles) DeathBubbles;
void() PainSound =
{
local float rs;
if (self.health < 0)
return;
if (damage_attacker.classname == "teledeath")
{
sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
return;
}
// water pain sounds
if (self.watertype == CONTENT_WATER && self.waterlevel == 3)
{
DeathBubbles(1);
if (random() > 0.5)
sound (self, CHAN_VOICE, "player/drown1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, "player/drown2.wav", 1, ATTN_NORM);
return;
}
// slime pain sounds
if (self.watertype == CONTENT_SLIME)
{
// FIX ME put in some steam here
if (random() > 0.5)
sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
return;
}
if (self.watertype == CONTENT_LAVA)
{
if (random() > 0.5)
sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
return;
}
if (self.pain_finished > time)
{
self.axhitme = 0;
return;
}
self.pain_finished = time + 0.5;
// don't make multiple pain sounds right after each other
// ax pain sound
if (self.axhitme == 1)
{
self.axhitme = 0;
sound (self, CHAN_VOICE, "player/axhit1.wav", 1, ATTN_NORM);
return;
}
rs = rint((random() * 5) + 1);
self.noise = "";
if (rs == 1)
self.noise = "player/pain1.wav";
else if (rs == 2)
self.noise = "player/pain2.wav";
else if (rs == 3)
self.noise = "player/pain3.wav";
else if (rs == 4)
self.noise = "player/pain4.wav";
else if (rs == 5)
self.noise = "player/pain5.wav";
else
self.noise = "player/pain6.wav";
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
return;
};
void() player_pain1 = [ 92, player_pain2 ] {PainSound();/*self.weaponframe=0;*/};
void() player_pain2 = [ 93, player_pain3 ] {};
void() player_pain3 = [ 94, player_pain4 ] {};
void() player_pain4 = [ 95, player_run ] {};
void() player_painb1 = [ 96, player_painb2 ] {PainSound();/*self.weaponframe=0;*/};
void() player_painb2 = [ 97, player_painb3 ] {};
void() player_painb3 = [ 98, player_painb4 ] {};
void() player_painb4 = [ 99, player_run ] {};
void() player_painc1 = [ 100, player_painc2 ] {PainSound();/*self.weaponframe=0;*/};
void() player_painc2 = [ 101, player_painc3 ] {};
void() player_painc3 = [ 102, player_painc4 ] {};
void() player_painc4 = [ 103, player_run ] {};
void() player_pain =
{
local float which;
if (self.weaponframe)
return;
if (self.invisible_finished > time)
return; // eyes don't have pain frames
// if (self.weapon == IT_DAGGER)
// player_axpain1 ();
// else
which = rint((random() * 2) + 1);
if (which <= 1)
player_pain1 ();
else if (which <= 2)
player_painb1 ();
else
player_painc1 ();
};
void() player_diea1;
void() player_dieb1;
void() DeathBubblesSpawn =
{
local entity bubble;
if (self.owner.waterlevel != 3)
return;
bubble = spawn();
setmodel (bubble, "progs/s_bubble.spr");
setorigin (bubble, self.owner.origin + '0 0 24');
bubble.movetype = MOVETYPE_NOCLIP;
bubble.solid = SOLID_NOT;
bubble.velocity = '0 0 15';
bubble.nextthink = time + 0.5;
bubble.think = bubble_bob;
bubble.classname = "bubble";
bubble.frame = 0;
bubble.cnt = 0;
setsize (bubble, '-8 -8 -8', '8 8 8');
self.nextthink = time + 0.1;
self.think = DeathBubblesSpawn;
self.air_finished = self.air_finished + 1;
if (self.air_finished >= self.bubble_count)
remove(self);
};
void(float num_bubbles) DeathBubbles =
{
local entity bubble_spawner;
bubble_spawner = spawn();
setorigin (bubble_spawner, self.origin);
bubble_spawner.movetype = MOVETYPE_NONE;
bubble_spawner.solid = SOLID_NOT;
bubble_spawner.nextthink = time + 0.1;
bubble_spawner.think = DeathBubblesSpawn;
bubble_spawner.air_finished = 0;
bubble_spawner.owner = self;
bubble_spawner.bubble_count = num_bubbles;
return;
};
void() DeathSound =
{
local float rs;
// water death sounds
if (self.waterlevel == 3)
{
DeathBubbles(20);
sound (self, CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NONE);
return;
}
rs = rint ((random() * 4) + 1);
if (rs == 1)
self.noise = "player/death1.wav";
if (rs == 2)
self.noise = "player/death2.wav";
if (rs == 3)
self.noise = "player/death3.wav";
if (rs == 4)
self.noise = "player/death4.wav";
if (rs == 5)
self.noise = "player/death5.wav";
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NONE);
return;
};
void() PlayerDead =
{
self.nextthink = -1;
// allow respawn after a certain time
self.deadflag = DEAD_DEAD;
};
void() PlayerDie =
{
local float i;
self.items = self.items - (self.items & IT_INVISIBILITY);
self.invisible_finished = 0; // don't die as eyes
self.invincible_finished = 0;
self.super_damage_finished = 0;
self.radsuit_finished = 0;
self.modelindex = modelindex_player; // don't use eyes
/*
Koolio, don't drop anything on death
if (deathmatch || coop)
DropBackpack();
*/
self.weaponmodel="";
self.view_ofs = '0 0 -8';
self.deadflag = DEAD_DYING;
self.solid = SOLID_NOT;
self.flags = self.flags - (self.flags & FL_ONGROUND);
self.movetype = MOVETYPE_TOSS;
if (self.velocity_z < 10)
self.velocity_z = self.velocity_z + random()*300;
/*
Koolio, no gore
if (self.health < -40)
{
GibPlayer ();
return;
}
*/
DeathSound();
self.angles_x = 0;
self.angles_z = 0;
/* Koolio, no melee-specific death
if (self.weapon == IT_DAGGER)
{
player_die_ax1 ();
return;
}
*/
i = cvar("temp1");
if (!i)
i = 1 + floor(random()*3);
if (i == 1)
player_diea1();
else
player_dieb1();
GlowOff(); //Koolio, turn off glows
//Xsniper, remove glowing field effect if we were praying
if (self.effects & EF_BRIGHTFIELD)
{
self.effects = self.effects - EF_BRIGHTFIELD;
self.praying = 0;
}
//Xsniper, if we are on map "ewend" then disable deathmatch mode
if (world.model == "ewend2.bsp")
set_deathmatch(0);
};
void() set_suicide_frame =
{ // used by klill command and diconnect command <-- haha iD can't spellz0rz
if (self.model != "progs/player.mdl")
return; // allready gibbed
self.frame = $deatha11;
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_TOSS;
self.deadflag = DEAD_DEAD;
self.nextthink = -1;
};
void() player_diea1 = [ 104, player_diea2 ] {};
void() player_diea2 = [ 105, player_diea3 ] {};
void() player_diea3 = [ 106, player_diea4 ] {};
void() player_diea4 = [ 107, player_diea5 ] {};
void() player_diea5 = [ 108, player_diea6 ] {};
void() player_diea6 = [ 109, player_diea7 ] {};
void() player_diea7 = [ 110, player_diea7 ] {PlayerDead();};
void() player_dieb1 = [ 111, player_dieb2 ] {};
void() player_dieb2 = [ 112, player_dieb3 ] {};
void() player_dieb3 = [ 113, player_dieb4 ] {};
void() player_dieb4 = [ 114, player_dieb5 ] {};
void() player_dieb5 = [ 115, player_dieb6 ] {};
void() player_dieb6 = [ 116, player_dieb7 ] {};
void() player_dieb7 = [ 117, player_dieb8 ] {};
void() player_dieb8 = [ 118, player_dieb9 ] {};
void() player_dieb9 = [ 119, player_dieb10 ] {};
void() player_dieb10 = [ 120, player_dieb11 ] {};
void() player_dieb11 = [ 121, player_dieb12 ] {};
void() player_dieb12 = [ 122, player_dieb13 ] {};
void() player_dieb13 = [ 123, player_dieb14 ] {};
void() player_dieb14 = [ 124, player_dieb15 ] {};
void() player_dieb15 = [ 125, player_dieb16 ] {};
void() player_dieb16 = [ 126, player_dieb17 ] {};
void() player_dieb17 = [ 127, player_dieb18 ] {};
void() player_dieb18 = [ 128, player_dieb19 ] {};
void() player_dieb19 = [ 129, player_dieb20 ] {};
void() player_dieb20 = [ 130, player_dieb21 ] {};
void() player_dieb21 = [ 131, player_dieb22 ] {};
void() player_dieb22 = [ 132, player_dieb23 ] {};
void() player_dieb23 = [ 133, player_dieb24 ] {};
void() player_dieb24 = [ 134, player_dieb25 ] {};
void() player_dieb25 = [ 135, player_dieb26 ] {};
void() player_dieb26 = [ 136, player_dieb27 ] {};
void() player_dieb27 = [ 137, player_dieb28 ] {};
void() player_dieb28 = [ 138, player_dieb29 ] {};
void() player_dieb29 = [ 139, player_dieb30 ] {};
void() player_dieb30 = [ 140, player_dieb31 ] {};
void() player_dieb31 = [ 141, player_dieb32 ] {};
void() player_dieb32 = [ 141, player_dieb33 ] {};
void() player_dieb33 = [ 143, player_dieb33 ] {PlayerDead();};
//============================================================================
// Player Jumping and Landing
//============================================================================
void() player_jump1 = [ 144, player_jump2 ] {};
void() player_jump2 = [ 145, player_jump3 ] {};
void() player_jump3 = [ 146, player_jump3 ] {if ((self.jump_flag < -100) && (self.flags & FL_ONGROUND) && (self.health > 0))player_run();};
void() player_land1 = [ 147, player_land2 ] {};
void() player_land2 = [ 148, player_land3 ] {};
void() player_land3 = [ 149, player_run ] {};