1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-26 18:15:27 +00:00

CExplosion done

This commit is contained in:
Roman Masanin 2020-10-05 16:14:48 +03:00
parent 4867d9949d
commit e3273d7268
2 changed files with 25 additions and 22 deletions

View file

@ -53,6 +53,7 @@ CExplosion::ClearAllExplosions()
gaExplosion[i].m_nIteration = 0; gaExplosion[i].m_nIteration = 0;
gaExplosion[i].m_fStartTime = 0.0f; gaExplosion[i].m_fStartTime = 0.0f;
gaExplosion[i].m_bIsBoat = false; gaExplosion[i].m_bIsBoat = false;
gaExplosion[i].m_bIsMakeSound = true;
} }
} }
@ -365,6 +366,7 @@ CExplosion::Update()
case EXPLOSION_GRENADE: case EXPLOSION_GRENADE:
case EXPLOSION_ROCKET: case EXPLOSION_ROCKET:
case EXPLOSION_HELI: case EXPLOSION_HELI:
case EXPLOSION_HELI2:
case EXPLOSION_MINE: case EXPLOSION_MINE:
case EXPLOSION_BARREL: case EXPLOSION_BARREL:
if (CTimer::GetFrameCounter() & 1) { if (CTimer::GetFrameCounter() & 1) {
@ -383,8 +385,10 @@ CExplosion::Update()
point1.z += 5.0f; point1.z += 5.0f;
CColPoint colPoint; CColPoint colPoint;
CEntity *pEntity; CEntity *pEntity;
CWorld::ProcessVerticalLine(point1, -1000.0f, colPoint, pEntity, true, false, false, false, true, false, nil); if (CWorld::ProcessVerticalLine(point1, -1000.0f, colPoint, pEntity, true, false, false, false, true, false, nil))
explosion.m_fZshift = colPoint.point.z; explosion.m_fZshift = colPoint.point.z;
else
explosion.m_fZshift = explosion.m_vecPosition.z;
} }
float ff = ((float)explosion.m_nIteration * 0.55f); float ff = ((float)explosion.m_nIteration * 0.55f);
for (int i = 0; i < 5 * ff; i++) { for (int i = 0; i < 5 * ff; i++) {
@ -393,8 +397,6 @@ CExplosion::Update()
CVector pos = explosion.m_vecPosition; CVector pos = explosion.m_vecPosition;
pos.x += ff * Sin(angle); pos.x += ff * Sin(angle);
pos.y += ff * Cos(angle); pos.y += ff * Cos(angle);
pos.z += 5.0f; // what is the point of this?
pos.z = explosion.m_fZshift + 0.5f; pos.z = explosion.m_fZshift + 0.5f;
CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, color, CGeneral::GetRandomNumberInRange(-3.0f, 3.0f), CGeneral::GetRandomNumberInRange(-180.0f, 180.0f)); CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, color, CGeneral::GetRandomNumberInRange(-3.0f, 3.0f), CGeneral::GetRandomNumberInRange(-180.0f, 180.0f));
} }
@ -402,9 +404,10 @@ CExplosion::Update()
break; break;
case EXPLOSION_CAR: case EXPLOSION_CAR:
case EXPLOSION_CAR_QUICK: case EXPLOSION_CAR_QUICK:
case EXPLOSION_BOAT:
if (someTime >= 3500) { if (someTime >= 3500) {
if (explosion.m_pVictimEntity != nil && !explosion.m_bIsBoat) { if (explosion.m_pVictimEntity != nil) {
if ((CGeneral::GetRandomNumber() & 0xF) == 0) { if ((CGeneral::GetRandomNumber() & 0xF) == 0 && !explosion.m_bIsBoat) {
CVehicle *veh = (CVehicle*)explosion.m_pVictimEntity; CVehicle *veh = (CVehicle*)explosion.m_pVictimEntity;
uint8 component = CAR_WING_LR; uint8 component = CAR_WING_LR;
@ -415,16 +418,14 @@ CExplosion::Update()
if (veh->IsComponentPresent(component)) { if (veh->IsComponentPresent(component)) {
CVector componentPos; CVector componentPos;
veh->GetComponentWorldPosition(component, componentPos); veh->GetComponentWorldPosition(component, componentPos);
CParticle::AddJetExplosion(componentPos, 1.5f, 0.0f); CParticle::AddJetExplosion(componentPos, 0.5f, 0.0f);
} }
} }
if (CTimer::GetTimeInMilliseconds() > explosion.m_fStartTime) { if (CTimer::GetTimeInMilliseconds() > explosion.m_fStartTime) {
explosion.m_fStartTime = CTimer::GetTimeInMilliseconds() + 125 + (CGeneral::GetRandomNumber() & 0x7F); explosion.m_fStartTime = CTimer::GetTimeInMilliseconds() + 125 + (CGeneral::GetRandomNumber() & 0x7F);
CVector pos = explosion.m_pVictimEntity->GetPosition(); CVector pos = explosion.m_pVictimEntity->GetPosition();
for (int i = 0; i < (CGeneral::GetRandomNumber() & 1) + 1; i++) { for (int i = 0; i < (CGeneral::GetRandomNumber() & 1) + 1; i++)
CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, CVector(0.0f, 0.0f, 0.0f), nil, 3.5f, color); CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, CVector(0.0f, 0.0f, 0.0f), nil, 3.5f, color);
CParticle::AddParticle(PARTICLE_EXPLOSION_LARGE, pos, CVector(0.0f, 0.0f, 0.0f), nil, 5.5f, color);
}
} }
} }
if (CTimer::GetFrameCounter() & 1) { if (CTimer::GetFrameCounter() & 1) {
@ -451,13 +452,15 @@ CExplosion::Update()
CVector pos(x - 128, y - 128, (z % 128) + 1); CVector pos(x - 128, y - 128, (z % 128) + 1);
pos.Normalise(); pos.Normalise();
pos *= ff / 5.0f; pos *= (explosion.m_nIteration + 1) * ff / 5.0f;
pos += explosion.m_vecPosition; pos += explosion.m_vecPosition;
pos.z += 0.5f; pos.z += 0.5f;
CParticle::AddParticle(PARTICLE_EXPLOSION_LARGE, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, color, CGeneral::GetRandomNumberInRange(-3.0f, 3.0f), CGeneral::GetRandomNumberInRange(-180.0f, 180.0f)); CParticle::AddParticle(PARTICLE_EXPLOSION_LARGE, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, color, CGeneral::GetRandomNumberInRange(-3.0f, 3.0f), CGeneral::GetRandomNumberInRange(-180.0f, 180.0f));
} }
} }
break; break;
default:
break;
} }
if (someTime > 0) if (someTime > 0)
explosion.m_nIteration++; explosion.m_nIteration++;

View file

@ -37,18 +37,18 @@ class CExplosion
float m_fPower; float m_fPower;
float m_fZshift; float m_fZshift;
public: public:
static void Initialise();
static void ClearAllExplosions();
static void Shutdown();
static int8 GetExplosionActiveCounter(uint8 id);
static void ResetExplosionActiveCounter(uint8 id);
static uint8 GetExplosionType(uint8 id);
static CVector *GetExplosionPosition(uint8 id);
static bool DoesExplosionMakeSound(uint8 id); //done
static bool AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32 lifetime, bool isMakeSound = true); //done(new parametr in android ver is fix for one mission) static bool AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32 lifetime, bool isMakeSound = true); //done(new parametr in android ver is fix for one mission)
static void Update(); static void ClearAllExplosions(); //done
static bool TestForExplosionInArea(eExplosionType type, float x1, float x2, float y1, float y2, float z1, float z2); static bool DoesExplosionMakeSound(uint8 id); //done
static void RemoveAllExplosionsInArea(CVector pos, float radius); static int8 GetExplosionActiveCounter(uint8 id); //done
static CVector *GetExplosionPosition(uint8 id); //done
static uint8 GetExplosionType(uint8 id); //done, mb need change type to tExplosionType
static void Initialise(); //done
static void RemoveAllExplosionsInArea(CVector pos, float radius); //done
static void ResetExplosionActiveCounter(uint8 id); //done
static void Shutdown(); //done
static void Update(); //done
static bool TestForExplosionInArea(eExplosionType type, float x1, float x2, float y1, float y2, float z1, float z2); //done, not used
}; };
extern CExplosion gaExplosion[NUM_EXPLOSIONS]; extern CExplosion gaExplosion[NUM_EXPLOSIONS];