Fixes for ArmouryEntity and fixed grenade weapon switching.

This commit is contained in:
Marco Cawthorne 2017-12-28 19:56:54 -08:00
parent 6f682653b1
commit d37546c131
5 changed files with 63 additions and 11 deletions

View file

@ -122,9 +122,8 @@ void CSQC_DrawCenterprint( void ) {
vCenterPrintPos_y = vVideoMins_y + ( vVideoResolution_y / 2 ) - ( fCenterPrintLines - 4 );
for ( int i = 0; i < ( fCenterPrintLines ); i++ ) {
vCenterPrintPos_x = vVideoMins_x + ( vVideoResolution_x / 2 ) - ( stringwidth( sCenterPrintBuffer[ i ], FALSE ) / 2 );
drawstring( vCenterPrintPos + '1 1', sCenterPrintBuffer[ i ], '8 8', '0 0 0', fCenterPrintAlpha, 0 );
drawstring( vCenterPrintPos, sCenterPrintBuffer[ i ], '8 8', '1 1 1', fCenterPrintAlpha, 0 );
vCenterPrintPos_x = vVideoMins_x + ( vVideoResolution_x / 2 ) - ( stringwidth( sCenterPrintBuffer[ i ], FALSE, '12 12' ) / 2 );
drawstring( vCenterPrintPos, sCenterPrintBuffer[ i ], '12 12', '1 1 1', fCenterPrintAlpha, 0 );
vCenterPrintPos_y += 8;
}
}

View file

@ -81,8 +81,9 @@ void armoury_entity( void ) {
entity eOld = self;
self = other;
if ( iArmouryItems[ eOld.item ] < 32 ) {
// Only MP5 til PARA
if ( eOld.item < 14 ) {
if ( Weapon_SlotEmpty( Weapon_GetSlot( iArmouryItems[ eOld.item ] ) ) ) {
Weapon_AddItem( iArmouryItems[ eOld.item ] );
Weapon_Draw( iArmouryItems[ eOld.item ] );
@ -92,6 +93,49 @@ void armoury_entity( void ) {
}
} else {
// Equipment
if ( iArmouryItems[ eOld.item ] == EQUIPMENT_KEVLAR ) {
if ( self.armor != 100 ) {
self.armor = 100;
} else {
self = eOld;
return;
}
} else if ( iArmouryItems[ eOld.item ] == EQUIPMENT_HELMET ) {
if ( self.armor == 100 ) {
if ( !( self.iEquipment & EQUIPMENT_HELMET ) ) {
sound( self, CHAN_ITEM, "items/tr_kevlar.wav", 1, ATTN_IDLE );
} else {
self = eOld;
return;
}
} else {
if ( self.iEquipment & EQUIPMENT_HELMET ) {
self.armor = 100;
sound( self, CHAN_ITEM, "items/tr_kevlar.wav", 1, ATTN_IDLE );
} else {
self.armor = 100;
self.iEquipment = self.iEquipment | EQUIPMENT_HELMET;
sound( self, CHAN_ITEM, "items/tr_kevlar.wav", 1, ATTN_IDLE );
}
}
} else {
int iNades = self.iAmmo_FLASHBANG + self.iAmmo_HEGRENADE + self.iAmmo_SMOKEGRENADE;
if ( iNades < 3 ) {
if ( iArmouryItems[ eOld.item ] == WEAPON_FLASHBANG ) {
self.iAmmo_FLASHBANG++;
sound( self, CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_IDLE );
} else if ( iArmouryItems[ eOld.item ] == WEAPON_HEGRENADE ) {
self.iAmmo_HEGRENADE++;
sound( self, CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_IDLE );
} else if ( iArmouryItems[ eOld.item ] == WEAPON_SMOKEGRENADE ) {
self.iAmmo_SMOKEGRENADE++;
sound( self, CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_IDLE );
}
} else {
self = eOld;
return;
}
}
}
self = eOld;

View file

@ -259,13 +259,22 @@ Returns whether or not we have the given weapon already
=================
*/
float Weapon_AlreadyExists( float fWeapon ) {
if ( wptTable[ fWeapon ].iSlot == SLOT_PRIMARY ) {
if ( self.fSlotPrimary == fWeapon ) {
if ( fWeapon == WEAPON_FLASHBANG || fWeapon == WEAPON_HEGRENADE || fWeapon == WEAPON_SMOKEGRENADE ) {
int iNades = self.iAmmo_FLASHBANG + self.iAmmo_HEGRENADE + self.iAmmo_SMOKEGRENADE;
if ( iNades ) {
return TRUE;
} else {
return FALSE;
}
} else if ( wptTable[ fWeapon ].iSlot == SLOT_SECONDARY ) {
if ( self.fSlotSecondary == fWeapon ) {
return TRUE;
} else {
if ( wptTable[ fWeapon ].iSlot == SLOT_PRIMARY ) {
if ( self.fSlotPrimary == fWeapon ) {
return TRUE;
}
} else if ( wptTable[ fWeapon ].iSlot == SLOT_SECONDARY ) {
if ( self.fSlotSecondary == fWeapon ) {
return TRUE;
}
}
}
@ -524,7 +533,7 @@ Client-HUD call that switches to a specific weapon
=================
*/
void CSEv_PlayerSwitchWeapon_f( float fWeapon ) {
if ( Weapon_AlreadyExists( fWeapon ) == FALSE && fWeapon != WEAPON_KNIFE ) {
if ( ( Weapon_AlreadyExists( fWeapon ) == FALSE ) && ( fWeapon != WEAPON_KNIFE ) ) {
return;
}
if ( fWeapon != self.weapon ) {

Binary file not shown.

Binary file not shown.