MCPcopy Create free account
hub / github.com/diasurgical/devilution / BreakBarrel

Function BreakBarrel

Source/objects.cpp:4038–4105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4036}
4037
4038void BreakBarrel(int pnum, int i, int dam, BOOL forcebreak, int sendmsg)
4039{
4040 int oi;
4041 int xp, yp;
4042
4043 if (object[i]._oSelFlag == 0)
4044 return;
4045 if (forcebreak) {
4046 object[i]._oVar1 = 0;
4047 } else {
4048 object[i]._oVar1 -= dam;
4049 if (pnum != myplr && object[i]._oVar1 <= 0)
4050 object[i]._oVar1 = 1;
4051 }
4052 if (object[i]._oVar1 > 0) {
4053 if (deltaload)
4054 return;
4055
4056 PlaySfxLoc(IS_IBOW, object[i]._ox, object[i]._oy);
4057 return;
4058 }
4059
4060 object[i]._oBreak = -1;
4061 object[i]._oVar1 = 0;
4062 object[i]._oAnimFlag = 1;
4063 object[i]._oAnimFrame = 1;
4064 object[i]._oAnimDelay = 1;
4065 object[i]._oSolidFlag = FALSE;
4066 object[i]._oMissFlag = TRUE;
4067 object[i]._oSelFlag = 0;
4068 object[i]._oPreFlag = TRUE;
4069 if (deltaload != 0) {
4070 object[i]._oAnimCnt = 0;
4071 object[i]._oAnimFrame = object[i]._oAnimLen;
4072 object[i]._oAnimDelay = 1000;
4073 return;
4074 }
4075
4076 if (object[i]._otype == OBJ_BARRELEX) {
4077 PlaySfxLoc(IS_BARLFIRE, object[i]._ox, object[i]._oy);
4078 for (yp = object[i]._oy - 1; yp <= object[i]._oy + 1; yp++) {
4079 for (xp = object[i]._ox - 1; xp <= object[i]._ox + 1; xp++) {
4080 if (dMonster[xp][yp] > 0)
4081 MonsterTrapHit(dMonster[xp][yp] - 1, 1, 4, 0, 1, FALSE);
4082 if (dPlayer[xp][yp] > 0)
4083 PlayerMHit(dPlayer[xp][yp] - 1, -1, 0, 8, 16, 1, FALSE, 0);
4084 if (dObject[xp][yp] > 0) {
4085 oi = dObject[xp][yp] - 1;
4086 if (object[oi]._otype == OBJ_BARRELEX && object[oi]._oBreak != -1)
4087 BreakBarrel(pnum, oi, dam, TRUE, sendmsg);
4088 }
4089 }
4090 }
4091 } else {
4092 PlaySfxLoc(IS_BARREL, object[i]._ox, object[i]._oy);
4093 SetRndSeed(object[i]._oRndSeed);
4094 if (object[i]._oVar2 <= 1) {
4095 if (!object[i]._oVar3)

Callers 2

BreakObjectFunction · 0.85
SyncBreakObjFunction · 0.85

Calls 7

PlaySfxLocFunction · 0.85
PlayerMHitFunction · 0.85
SetRndSeedFunction · 0.85
CreateRndUsefulFunction · 0.85
CreateRndItemFunction · 0.85
SpawnSkeletonFunction · 0.85
NetSendCmdParam2Function · 0.85

Tested by

no test coverage detected