Press [\] to break window glass with crowbar or any two-handed weapon. Weapon can be damaged in the process.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9368 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2022-04-21 13:00:09 +00:00
parent 02a8c48873
commit cdc605d5ab
6 changed files with 114 additions and 2 deletions
+11 -1
View File
@@ -4656,4 +4656,14 @@ INT32 GetBPCostForRecoilkick( SOLDIERTYPE * pSoldier )
iKickPower = max(0, iKickPower);
return ( iKickPower );
}
}
INT16 GetAPsToBreakWindow(SOLDIERTYPE *pSoldier, BOOLEAN fStance)
{
if (fStance)
{
return MinAPsToPunch(pSoldier, pSoldier->sGridNo);
}
return MinAPsToPunch(pSoldier, NOWHERE);
}
+3
View File
@@ -387,4 +387,7 @@ INT16 GetBPsToJumpWall( SOLDIERTYPE *pSoldier, BOOLEAN fClimbDown );
INT32 GetBPCostPer10APsForGunHolding( SOLDIERTYPE * pSoldier, BOOLEAN fEstimate = FALSE );
INT32 GetBPCostForRecoilkick( SOLDIERTYPE * pSoldier );
// sevenfm
INT16 GetAPsToBreakWindow(SOLDIERTYPE *pSoldier, BOOLEAN fStance);
#endif
+31 -1
View File
@@ -376,6 +376,36 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
case 430:
{
// sevenfm: breaking window with crowbar code
if (pSoldier->inv[HANDPOS].exists() &&
(Item[pSoldier->inv[HANDPOS].usItem].crowbar && Item[pSoldier->inv[HANDPOS].usItem].usItemClass & (IC_PUNCH) ||
Item[pSoldier->inv[HANDPOS].usItem].usItemClass & IC_GUN && Item[pSoldier->inv[HANDPOS].usItem].twohanded && Item[pSoldier->inv[HANDPOS].usItem].metal))
{
INT32 sWindowGridNo = pSoldier->sTargetGridNo;
if (pSoldier->ubDirection == NORTH || pSoldier->ubDirection == WEST)
sWindowGridNo = NewGridNo(pSoldier->sGridNo, (UINT16)DirectionInc((UINT8)pSoldier->ubDirection));
// is there really an intact window that we jump through?
if (IsJumpableWindowPresentAtGridNo(sWindowGridNo, pSoldier->ubDirection, TRUE) && !IsJumpableWindowPresentAtGridNo(sWindowGridNo, pSoldier->ubDirection, FALSE))
{
STRUCTURE * pStructure = FindStructure(sWindowGridNo, STRUCTURE_WALLNWINDOW);
if (pStructure && !(pStructure->fFlags & STRUCTURE_OPEN))
{
// intact window found. Smash it!
WindowHit(sWindowGridNo, pStructure->usStructureID, (pSoldier->ubDirection == SOUTH || pSoldier->ubDirection == EAST), TRUE);
// damage weapon
if (Chance(50 - 10 * min(5, Item[pSoldier->inv[HANDPOS].usItem].bReliability)))
{
pSoldier->inv[HANDPOS][0]->data.objectStatus--;
if (Random(100) < Item[pSoldier->inv[HANDPOS].usItem].usDamageChance)
{
pSoldier->inv[HANDPOS][0]->data.sRepairThreshold--;
}
}
}
}
}
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,"AdjustToNextAnimationFrame: case 430");
// SHOOT GUN
// MAKE AN EVENT, BUT ONLY DO STUFF IF WE OWN THE GUY!
@@ -386,7 +416,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
SFireWeapon.bTargetCubeLevel= pSoldier->bTargetCubeLevel;
if((is_server && pSoldier->ubID<120) || (!is_server && is_client && pSoldier->ubID<20) || (!is_server && !is_client) )
{
//only carry on if own werc
//only carry on if own merc
AddGameEvent( S_FIREWEAPON, 0, &SFireWeapon );
//hayden
+52
View File
@@ -24402,6 +24402,58 @@ void BeginSoldierClimbWallUp( SOLDIERTYPE *pSoldier )
}
//------------------------------------------------------------------------------------------
void SOLDIERTYPE::BreakWindow(void)
{
if (this->inv[HANDPOS].exists() &&
this->inv[HANDPOS][0]->data.objectStatus >= USABLE &&
(Item[this->inv[HANDPOS].usItem].crowbar && Item[this->inv[HANDPOS].usItem].usItemClass & (IC_PUNCH) ||
Item[this->inv[HANDPOS].usItem].usItemClass & IC_GUN && Item[this->inv[HANDPOS].usItem].twohanded && Item[this->inv[HANDPOS].usItem].metal))
{
this->usAttackingWeapon = this->inv[HANDPOS].usItem;
this->aiData.bAction = AI_ACTION_KNIFE_STAB;
this->aiData.usActionData = this->sGridNo;
this->aiData.ubPendingAction = NO_PENDING_ACTION;
this->sTargetGridNo = this->sGridNo;
this->bTargetLevel = this->pathing.bLevel;
//this->sLastTarget = sGridNo; //dnl ch73 021013
this->ubTargetID = NOBODY; //WhoIsThere2(this->sTargetGridNo, this->bTargetLevel);
this->EVENT_InitNewSoldierAnim(CROWBAR_ATTACK, 0, FALSE);
SetUIBusy(this->ubID);
DeductPoints(this, GetAPsToBreakWindow(this, FALSE), BP_USE_CROWBAR);
}
}
BOOLEAN SOLDIERTYPE::CanBreakWindow(void)
{
if (this->stats.bLife >= OKLIFE &&
!this->IsUnconscious() &&
IS_MERC_BODY_TYPE(this) &&
this->inv[HANDPOS].exists() &&
this->inv[HANDPOS][0]->data.objectStatus >= USABLE &&
(Item[this->inv[HANDPOS].usItem].crowbar && Item[this->inv[HANDPOS].usItem].usItemClass & (IC_PUNCH) ||
Item[this->inv[HANDPOS].usItem].usItemClass & IC_GUN && Item[this->inv[HANDPOS].usItem].twohanded && Item[this->inv[HANDPOS].usItem].metal))
{
//INT32 sWindowGridNo = this->sTargetGridNo;
INT32 sWindowGridNo = this->sGridNo;
if (this->ubDirection == NORTH || this->ubDirection == WEST)
sWindowGridNo = NewGridNo(this->sGridNo, (UINT16)DirectionInc((UINT8)this->ubDirection));
// is there really an intact window that we jump through?
if (IsJumpableWindowPresentAtGridNo(sWindowGridNo, this->ubDirection, TRUE) && !IsJumpableWindowPresentAtGridNo(sWindowGridNo, this->ubDirection, FALSE))
{
STRUCTURE * pStructure = FindStructure(sWindowGridNo, STRUCTURE_WALLNWINDOW);
if (pStructure && !(pStructure->fFlags & STRUCTURE_OPEN))
{
// intact window found
return TRUE;
}
}
}
return FALSE;
}
BOOLEAN DoesSoldierWearGasMask( SOLDIERTYPE *pSoldier )//dnl ch40 200909
{
INT8 bPosOfMask = FindGasMask( pSoldier );
+3
View File
@@ -1789,6 +1789,9 @@ public:
void ChangeToFlybackAnimation( UINT8 flyBackDirection );
void ChangeToFallbackAnimation( UINT8 fallBackDirection );
// sevenfm
void BreakWindow(void);
BOOLEAN CanBreakWindow(void);
void UpdateRobotControllerGivenController( void );
void UpdateRobotControllerGivenRobot( void );
+14
View File
@@ -2959,6 +2959,20 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
}
break;
case '\\':
if (gusSelectedSoldier != NOBODY)
{
SOLDIERTYPE *pSoldier;
if (GetSoldier(&pSoldier, gusSelectedSoldier))
{
if (pSoldier->CanBreakWindow() && EnoughPoints(pSoldier, GetAPsToBreakWindow(pSoldier, TRUE), BP_USE_CROWBAR, TRUE))
pSoldier->BreakWindow();
//else if (pSoldier->CanStartDrag())
//pSoldier->StartDrag();
}
}
break;
#if 0//dnl ch75 021113
case '\"':
Testing(1);