/* 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. */ .entity eUser; float Client_LerpCamera( float fStart, float fEnd, float fAmount ) { float shortest_angle = ( ( ( ( fEnd - fStart ) % 360 ) + 540 ) % 360 ) - 180; return shortest_angle * fAmount; } void hostage_pain( void ) { self.frame = 13 - ceil( random() * 5); } void hostage_die( void ) { sound( world, CHAN_VOICE, "radio/hosdown.wav", 1.0, ATTN_NONE ); self.frame = 30 + ceil( random() * 5); self.solid = SOLID_NOT; self.takedamage = DAMAGE_NO; } 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; if ( ( self.eUser != world ) && ( self.health > 0 ) ) { // 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; } /* ================= SPAWN: hostage_entity Entry function for the hostages. ================= */ void hostage_entity( void ) { precache_model( self.model ); setorigin( self, self.origin ); 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' ); self.customphysics = hostage_physics; self.eUser = world; self.iUsable = TRUE; self.iBleeds = TRUE; self.takedamage = DAMAGE_YES; self.vUse = hostage_use; self.vPain = hostage_pain; self.vDeath = hostage_die; self.frame = 13; // Idle frame self.health = 100; iHostagesMax = iHostagesMax + 1; // Increase the global count of hostages }