C4 icon is now flashing when in zone + bomb equipped

Fixed bug in which switching entities in the game-logic caused pretty bad bugs
Respawn fixes for hostage, ambient_generic and cylcer_sprite entities
Fixed a bug in which func_door's would call the targets twice
Added the missing spawnflag support for "Initially Dark" light entities
This commit is contained in:
Marco Hladik 2016-12-08 00:09:50 +01:00
parent 1290fb0daf
commit a15b5f606f
20 changed files with 147 additions and 92 deletions

View File

@ -147,7 +147,16 @@ void HUD_DrawIcons( void ) {
// Bomb-Area
if( getstatf( STAT_BOMBZONE ) == TRUE ) {
vector vBIconPos = [ 16, ( vVideoResolution_y / 2 ) + 24 ];
drawsubpic( vBIconPos, '32 32 0', HUD_NUMFILE_LAYER, [ 0, 0.125 * 5 - 0.046875], [ 0.125, 0.125 ], '0 1 0', 1, DRAWFLAG_ADDITIVE );
if ( getstatf( STAT_ACTIVEWEAPON ) == WEAPON_C4BOMB ) {
float fAlpha = fabs( sin( time * 20 ) );
drawsubpic( vBIconPos, '32 32 0', HUD_NUMFILE_LAYER, [ 0, 0.125 * 5 - 0.046875], [ 0.125, 0.125 ], '1 0 0', fAlpha, DRAWFLAG_ADDITIVE );
drawsubpic( vBIconPos, '32 32 0', HUD_NUMFILE_LAYER, [ 0, 0.125 * 5 - 0.046875], [ 0.125, 0.125 ], '0 1 0', 1 - fAlpha, DRAWFLAG_ADDITIVE );
} else {
drawsubpic( vBIconPos, '32 32 0', HUD_NUMFILE_LAYER, [ 0, 0.125 * 5 - 0.046875], [ 0.125, 0.125 ], '0 1 0', 1, DRAWFLAG_ADDITIVE );
}
}
}

View File

@ -1,6 +1,6 @@
#pragma target fte
#pragma progs_dat "../../Main/csprogs.dat"
#pragma progs_dat "../../cstrike/csprogs.dat"
#define CSQC

View File

@ -56,14 +56,27 @@ void ambient_generic( void ) {
sound( self, CHAN_VOICE, self.message, self.health, self.style );
}
static void ambient_generic_useloop( void ) {
//self.message = "common/null.wav";
self.SendFlags = 128;
if ( self.state == TRUE ) {
self.message = "common/null.wav";
self.SendFlags = 128;
self.state = FALSE;
} else {
self.message = self.noise;
self.SendFlags = 128;
self.state = TRUE;
}
}
static void ambient_generic_respawn( void ) {
// If we are supposed to be looping, but have stopped playing... make sure we do again
if( !( self.spawnflags & 32 ) && ( self.state == FALSE ) ) {
ambient_generic_useloop();
}
}
precache_sound( self.message );
setorigin( self, self.origin );
self.health = self.health / 10;
if ( self.spawnflags & 1 ) {
self.style = ATTN_NONE;
} else if ( self.spawnflags & 2 ) {
@ -79,12 +92,14 @@ void ambient_generic( void ) {
if( self.spawnflags & 32 ) {
self.vUse = ambient_generic_use;
} else {
self.noise = self.message; // Needed later for resuming
self.pvsflags = PVSF_NOREMOVE | PVSF_IGNOREPVS;
self.vUse = ambient_generic_useloop;
self.SendEntity = ambient_generic_send;
self.state = TRUE;
}
Entities_InitRespawnable( ambient_generic_respawn );
}
#else
void CSQC_ambient_generic( string sSample, float fVolume, float fAttenuation ) {

View File

@ -27,14 +27,14 @@ void Damage_Apply( entity eTarget, entity eAttacker, int iDamage, vector vHitPos
pointparticles( EFFECT_BLOOD, vHitPos, v_forward * -1, 1 );
}
eOld = self;
entity eOld = self;
self = eTarget;
if ( eTarget.health <= 0 ) {
eTarget.health = 0;
eTarget.vDeath();
if ( self.health <= 0 ) {
self.health = 0;
self.vDeath();
} else {
eTarget.vPain();
self.vPain();
}
self = eOld;

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define VEC_HULL_MIN '-16 -16 -36'
#define VEC_HULL_MAX '16 16 36'
#define VEC_PLAYER_VIEWPOS '0 0 24'
#define VEC_PLAYER_VIEWPOS '0 0 20'
#define VEC_CHULL_MIN '-16 -16 -18'
#define VEC_CHULL_MAX '16 16 18'
@ -61,12 +61,14 @@ float fGameTime;
// Game specific fields
int iHostagesMax;
int iHostagesRescued;
int iBombZones;
int iRescueZones;
int iBuyZones;
int iBuyRestriction; // For info_map_parameters
int iHostagesRescued;
int iBombPlanted;
// Generic entity fields
.int iUsable;
.int iBleeds;
@ -119,7 +121,5 @@ void Damage_Radius( vector vOrigin, entity eAttacker, float fDamage, float fRadi
void Entities_InitRespawnable( void() vRespawnFunc );
void Entities_Respawn( void );
entity eOld;
// WIP
string __fullspawndata;

View File

@ -181,6 +181,7 @@ void hostage_entity( void ) {
self.frame = 13; // Idle frame
self.health = 100;
self.velocity = '0 0 0';
}
precache_model( self.model );

View File

@ -18,6 +18,38 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
====================
GOLDSRC-RENDERMODE STUFF
====================
*/
enum {
RENDERMODE_NORMAL = 0,
RENDERMODE_COLOR,
RENDERMODE_TEXTURE,
RENDERMODE_GLOW,
RENDERMODE_SOLID,
RENDERMODE_ADDITIVE
};
void Entities_RenderSetup( void ) {
// GoldSrc-Rendermode support
if ( self.rendermode != RENDERMODE_NORMAL ) {
self.alpha = ( self.renderamt / 255 );
self.colormod = self.rendercolor;
if( self.alpha == 0 ) {
self.alpha = 0.0001;
}
if ( self.rendermode == RENDERMODE_ADDITIVE ) {
self.effects = EF_ADDITIVE;
} else if ( self.rendermode == RENDERMODE_GLOW ) {
self.effects = EF_ADDITIVE | EF_FULLBRIGHT;
}
}
}
/*
====================
Entities_UseTargets
@ -26,16 +58,15 @@ Entities_UseTargets
void Entities_UseTargets( void ) {
entity eFind = findchain( targetname, self.target );
entity eOld = self;
while ( eFind ) {
eOld = self;
self = eFind;
eFind.vUse();
self = eOld;
self.vUse();
eFind = eFind.chain;
}
self = eOld;
}
/*
====================
Entities_UseTargets_Delay
@ -43,7 +74,7 @@ Entities_UseTargets_Delay
*/
void Entities_UseTargets_Delay( float fDelay ) {
static void Entities_UseTargets_Delay_Think( void ) {
eOld = self;
entity eOld = self;
self = self.owner;
Entities_UseTargets();
remove( eOld );
@ -53,7 +84,6 @@ void Entities_UseTargets_Delay( float fDelay ) {
eTimer.owner = self;
eTimer.think = Entities_UseTargets_Delay_Think;
eTimer.nextthink = time + fDelay;
}
/*
@ -68,9 +98,6 @@ Called
.float fOldHealth;
.vector vOldOrigin;
.vector vOldAngle;
.float fOldAlpha;
.vector vOldColorMod;
.float fOldEffects;
.void() vRespawn;
void Entities_InitRespawnable( void() vRespawnFunc ) {
self.sOldModel = self.model;
@ -78,9 +105,6 @@ void Entities_InitRespawnable( void() vRespawnFunc ) {
self.fOldHealth = self.health;
self.vOldOrigin = self.origin;
self.vOldAngle = self.angles;
self.fOldAlpha = self.alpha;
self.vOldColorMod = self.colormod;
self.fOldEffects = self.effects;
self.vRespawn = vRespawnFunc;
self.fRespawns = TRUE;
}
@ -91,9 +115,7 @@ void Entities_Respawn( void ) {
self.health = self.fOldHealth;
self.origin = self.vOldOrigin;
self.angles = self.vOldAngle;
self.alpha = self.fOldAlpha;
self.colormod = self.vOldColorMod;
self.effects = self.fOldEffects;
Entities_RenderSetup();
self.vRespawn();
}
@ -241,39 +263,6 @@ void Entities_RotateToDestination( vector vDestinationAngle, float fTravelSpeed,
self.think = Entities_RotateToDestination_End;
}
/*
====================
GOLDSRC-RENDERMODE STUFF
====================
*/
enum {
RENDERMODE_NORMAL = 0,
RENDERMODE_COLOR,
RENDERMODE_TEXTURE,
RENDERMODE_GLOW,
RENDERMODE_SOLID,
RENDERMODE_ADDITIVE
};
void Entities_RenderSetup( void ) {
// GoldSrc-Rendermode support
if ( self.rendermode != RENDERMODE_NORMAL ) {
self.alpha = ( self.renderamt / 255 );
self.colormod = self.rendercolor;
if( self.alpha == 0 ) {
self.alpha = 0.0001;
}
if ( self.rendermode == RENDERMODE_ADDITIVE ) {
self.effects = EF_ADDITIVE;
} else if ( self.rendermode == RENDERMODE_GLOW ) {
self.effects = EF_ADDITIVE | EF_FULLBRIGHT;
}
}
}
void func_wall( void ) {
static void func_wall_use( void ) {
self.skin = 1 - self.skin;

View File

@ -33,10 +33,15 @@ Frames per second (framerate) - Framerate the sprite will run at if animated.
=================
*/
void cycler_sprite( void ) {
static void cycler_sprite_respawn( void ) {
// Find something to do here...
}
precache_model( self.model );
setmodel( self, self.model );
Entities_RenderSetup();
Entities_InitRespawnable( cycler_sprite_respawn );
}
void env_glow( void ) {

View File

@ -24,6 +24,9 @@ func_bomb_target_touch
=================
*/
void func_bomb_target_touch( void ) {
if ( iBombPlanted == TRUE ) {
return;
}
if ( ( other.classname == "player" ) && ( other.team == TEAM_T ) ) {
other.fInBombZone = TRUE; // Note: this will be cleared every frame inside SV_RunClientCommand
}

View File

@ -170,9 +170,11 @@ void func_breakable( void ) {
self.touch = func_breakable_touch;
}
self.health = 100;
self.vUse = func_breakable_die;
}
func_wall();
func_breakable_respawn();

View File

@ -63,35 +63,36 @@ Called by StartFrame if we somehow got no buy zones
*/
void Game_CreateBuyZones( void ) {
entity eFind;
entity eOld;
if ( iBuyRestriction == BUY_T || iBuyRestriction == BUY_BOTH ) {
eFind = findchain( classname, "info_player_deathmatch" );
eOld = self;
while ( eFind ) {
entity eBuyZoneT = spawn();
setorigin( eBuyZoneT, eFind.origin );
eOld = self;
self = eBuyZoneT;
func_buyzone();
self.team = TEAM_T;
self = eOld;
eFind = eFind.chain;
}
self = eOld;
}
if ( iBuyRestriction == BUY_CT || iBuyRestriction == BUY_BOTH ) {
eFind = findchain( classname, "info_player_start" );
eOld = self;
while ( eFind ) {
entity eBuyZoneCT = spawn();
setorigin( eBuyZoneCT, eFind.origin );
eOld = self;
self = eBuyZoneCT;
func_buyzone();
self.team = TEAM_CT;
self = eOld;
eFind = eFind.chain;
}
self = eOld;
}
}

View File

@ -160,7 +160,6 @@ void FuncDoor_MoveAway( void ) {
self.state = STATE_UP;
Entities_MoveToDestination ( self.pos2, self.speed, FuncDoor_Arrived );
Entities_UseTargets();
}
/*
@ -169,17 +168,20 @@ FuncDoor_Trigger
====================
*/
void FuncDoor_Trigger( void ) {
// Only trigger stuff when we are done moving
if ( ( self.state == STATE_RAISED ) || ( self.state == STATE_LOWERED ) ) {
if ( self.delay > 0 ) {
Entities_UseTargets_Delay( self.delay );
} else {
Entities_UseTargets();
}
}
if ( ( self.state == STATE_UP ) || ( self.state == STATE_RAISED ) ){
FuncDoor_MoveBack();
return;
}
if ( self.delay ) {
Entities_UseTargets_Delay( self.delay );
} else {
Entities_UseTargets();
}
FuncDoor_MoveAway();
}

View File

@ -36,7 +36,7 @@ void func_hostage_rescue_touch( void ) {
remove( other.eTargetPoint );
}
eOld = self;
entity eOld = self;
self = other;
Entities_Remove();
self = eOld;
@ -44,6 +44,7 @@ void func_hostage_rescue_touch( void ) {
if ( iHostagesRescued >= iHostagesMax ) {
// TODO: Broadcast_Print: All Hostages have been rescued!
Rules_RoundOver( TEAM_CT );
iHostagesRescued = 0;
}
}
}
@ -92,7 +93,7 @@ void Game_CreateRescueZones( void ) {
entity eRescueZone = spawn();
setorigin( eRescueZone, eFind.origin );
eOld = self;
entity eOld = self;
self = eRescueZone;
info_hostage_rescue();
self = eOld;

View File

@ -18,17 +18,38 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
=================
light
Only thing this ent does, is allow the change of lightstyles.
You can use custom patterns, too.
=================
*/
.string pattern;
void light( void ) {
static void light_toggle( void ) {
if ( self.health == TRUE ) {
lightstyle( self.style, "a" );
self.health = FALSE;
} else {
lightstyle( self.style, "m" );
lightstyle( self.style, self.pattern );
self.health = TRUE;
}
}
if ( !self.pattern ) {
self.pattern = "m";
}
if ( self.spawnflags & 1 ) {
lightstyle( self.style, "a" );
self.health = FALSE;
} else {
lightstyle( self.style, self.pattern );
self.health = TRUE;
}
self.vUse = light_toggle;
self.health = TRUE;
}

View File

@ -38,7 +38,8 @@ void Player_Death( void ) {
if ( self.team == TEAM_T ) {
iAlivePlayers_T--;
if ( iAlivePlayers_T == 0 ) {
// If the bomb has been planted, T deaths don't matter anymore
if ( iAlivePlayers_T == 0 && iBombPlanted == FALSE ) {
Rules_RoundOver( TEAM_CT );
}
} else if ( self.team == TEAM_CT ) {

View File

@ -59,9 +59,10 @@ float Rules_BuyingPossible( void ) {
// Loop through all players and respawn them
void Rules_Restart( void ) {
entity eFind = findchain( classname, "player" );
entity eOld = self;
while ( eFind ) {
eOld = self;
self = eFind;
if ( self.health > 0 ) {
@ -70,10 +71,11 @@ void Rules_Restart( void ) {
Spawn_CreateClient( self.fCharModel );
}
self = eOld;
eFind = eFind.chain;
}
self = eOld;
// Select a random Terrorist for the bomb thing
if ( iBombZones > 0 ) {
int iRandomT = ceil( random() * iAlivePlayers_T );
@ -100,13 +102,15 @@ void Rules_Restart( void ) {
// Respawn all the entities
eFind = findchainfloat( fRespawns , TRUE );
eOld = self;
while ( eFind ) {
eOld = self;
self = eFind;
Entities_Respawn();
self = eOld;
eFind = eFind.chain;
}
self = eOld;
Timer_Begin( cvar( "mp_freezetime" ), GAME_FREEZE );
}

View File

@ -32,14 +32,15 @@ void trigger_multiple( void ) {
if ( self.killtarget ) {
entity eFind = findchain( killtarget, self.target );
entity eOld = self;
while ( eFind ) {
entity eRemoveMe = eFind;
eOld = self;
self = eRemoveMe;
Entities_Remove();
self = eOld;
eFind = eFind.chain;
}
self = eOld;
}
}

View File

@ -1,6 +1,6 @@
#pragma target fte
#pragma progs_dat "../../Main/progs.dat"
#pragma progs_dat "../../cstrike/progs.dat"
#includelist
../Builtins.h
@ -46,7 +46,6 @@ Timer.c
EntHostage.c
Entities.c
Triggers.c
AmbientSound.c
EnvObjects.c
FuncBreakable.c
FuncLadder.c
@ -56,6 +55,7 @@ FuncBuyZone.c
FuncButton.c
FuncDoor.c
FuncDoorRotating.c
AmbientSound.c
Light.c
Main.c

View File

@ -64,6 +64,7 @@ void WeaponC4BOMB_Drop( vector vBombPos ) {
sound( self, CHAN_VOICE, "weapons/c4_explode1.wav", 1.0, ATTN_NONE );
Damage_Radius( self.origin, self.owner, 500, 1024 );
remove( self );
iBombPlanted = FALSE;
return;
}
@ -90,7 +91,7 @@ void WeaponC4BOMB_Drop( vector vBombPos ) {
sound( eBomb, CHAN_WEAPON, "weapons/c4_plant.wav", 1.0, ATTN_IDLE );
Radio_BroadcastMessage( RADIO_BOMBPL );
iBombPlanted = TRUE;
Weapon_SwitchBest();
}
#endif

View File

@ -79,7 +79,6 @@ void WeaponUSP45_Draw( void ) {
}
Sound_Delayed( "weapons/usp_slideback.wav", 1.0, 0.5 );
print( "EXECUTED TWICE?????\n" );
#endif
}