2016-12-01 17:50:48 +00:00
|
|
|
/*
|
|
|
|
OpenCS Project
|
|
|
|
Copyright (C) 2015 Marco "eukara" Hladik
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2016-12-02 16:54:40 +00:00
|
|
|
.entity eUser;
|
|
|
|
|
|
|
|
float Client_LerpCamera( float fStart, float fEnd, float fAmount ) {
|
|
|
|
float shortest_angle = ( ( ( ( fEnd - fStart ) % 360 ) + 540 ) % 360 ) - 180;
|
|
|
|
return shortest_angle * fAmount;
|
|
|
|
}
|
|
|
|
|
2016-12-02 23:12:10 +00:00
|
|
|
void hostage_pain( void ) {
|
|
|
|
self.frame = 13 - ceil( random() * 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void hostage_die( void ) {
|
2016-12-03 00:35:50 +00:00
|
|
|
sound( world, CHAN_VOICE, "radio/hosdown.wav", 1.0, ATTN_NONE );
|
2016-12-02 23:12:10 +00:00
|
|
|
self.frame = 30 + ceil( random() * 5);
|
|
|
|
self.solid = SOLID_NOT;
|
|
|
|
self.takedamage = DAMAGE_NO;
|
|
|
|
}
|
|
|
|
|
2016-12-02 16:54:40 +00:00
|
|
|
void hostage_use( void ) {
|
|
|
|
if ( self.eUser == world ) {
|
|
|
|
sound( self, CHAN_VOICE, sprintf( "hostage/hos%d.wav", ceil( random() * 5 ) ), 1.0, ATTN_IDLE );
|
|
|
|
self.eUser = eActivator;
|
|
|
|
} else {
|
|
|
|
self.eUser = world;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void hostage_physics( void ) {
|
|
|
|
input_movevalues = '0 0 0';
|
|
|
|
input_impulse = 0;
|
|
|
|
input_buttons = 0;
|
|
|
|
input_angles = self.angles;
|
|
|
|
|
2016-12-02 23:12:10 +00:00
|
|
|
if ( ( self.eUser != world ) && ( self.health > 0 ) ) {
|
2016-12-02 16:54:40 +00:00
|
|
|
// This is visible ingame, so this is definitely executed.
|
|
|
|
vector vEndAngle = vectoangles( self.eUser.origin - self.origin );
|
|
|
|
self.angles_y += Client_LerpCamera( self.angles_y, vEndAngle_y, 0.2 );
|
|
|
|
|
|
|
|
// Just make them move forward right now
|
|
|
|
// TODO: trace the dist to determine whether or not we should back off
|
|
|
|
float fDist = vlen( self.eUser.origin - self.origin );
|
|
|
|
|
|
|
|
if ( fDist < 130 ) {
|
|
|
|
self.frame = 13;
|
|
|
|
input_movevalues = '0 0 0';
|
|
|
|
} else if ( fDist < 200 ) {
|
|
|
|
self.frame = 0;
|
|
|
|
input_movevalues = '110 0 0';
|
|
|
|
} else {
|
|
|
|
self.frame = 2;
|
|
|
|
input_movevalues = '220 0 0';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tricking the engine
|
|
|
|
self.movetype = MOVETYPE_WALK;
|
|
|
|
runstandardplayerphysics( self );
|
|
|
|
self.customphysics = hostage_physics;
|
|
|
|
}
|
|
|
|
|
2016-12-01 17:50:48 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
SPAWN: hostage_entity
|
|
|
|
|
|
|
|
Entry function for the hostages.
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void hostage_entity( void ) {
|
|
|
|
precache_model( self.model );
|
2016-12-02 16:54:40 +00:00
|
|
|
setorigin( self, self.origin );
|
2016-12-01 17:50:48 +00:00
|
|
|
self.solid = SOLID_SLIDEBOX;
|
|
|
|
self.movetype = MOVETYPE_WALK;
|
|
|
|
setmodel( self, self.model );
|
|
|
|
setsize( self, VEC_HULL_MIN + '0 0 36', VEC_HULL_MAX + '0 0 36' );
|
2016-12-02 16:54:40 +00:00
|
|
|
self.customphysics = hostage_physics;
|
|
|
|
|
|
|
|
self.eUser = world;
|
|
|
|
self.iUsable = TRUE;
|
2016-12-02 23:12:10 +00:00
|
|
|
self.iBleeds = TRUE;
|
|
|
|
self.takedamage = DAMAGE_YES;
|
2016-12-02 16:54:40 +00:00
|
|
|
self.vUse = hostage_use;
|
2016-12-02 23:12:10 +00:00
|
|
|
self.vPain = hostage_pain;
|
|
|
|
self.vDeath = hostage_die;
|
2016-12-01 17:50:48 +00:00
|
|
|
|
|
|
|
self.frame = 13; // Idle frame
|
2016-12-02 16:54:40 +00:00
|
|
|
self.health = 100;
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2016-12-02 16:54:40 +00:00
|
|
|
iHostagesMax = iHostagesMax + 1; // Increase the global count of hostages
|
2016-12-01 17:50:48 +00:00
|
|
|
}
|