From d0213e466c02974b5aaba0d1fad334ff9281f6cc Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 7 Jun 2020 15:49:25 +0300 Subject: [PATCH] more script commands --- src/control/Script.cpp | 52 +++++++++++++++++++++++++-------------- src/entities/Physical.cpp | 2 +- src/peds/Ped.cpp | 11 +++++---- src/peds/Ped.h | 4 +-- src/vehicles/Bike.cpp | 6 ++--- 5 files changed, 46 insertions(+), 29 deletions(-) diff --git a/src/control/Script.cpp b/src/control/Script.cpp index d7a0486a..686154fa 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -10772,13 +10772,22 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_HELI_ORIENTATION: { CollectParameters(&m_nIp, 2); - debug("SET_HELI_ORIENTATION is not implemented\n"); // TODO(MIAMI); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli()); + float fAngle = DEGTORAD(*(float*)&ScriptParams[1] - 90.0f); + while (fAngle < 0.0f) + fAngle += TWOPI; + while (fAngle > TWOPI) + fAngle -= TWOPI; + pHeli->SetHeliOrientation(fAngle); return 0; } case COMMAND_CLEAR_HELI_ORIENTATION: { CollectParameters(&m_nIp, 1); - debug("SET_HELI_ORIENTATION is not implemented\n"); // TODO(MIAMI); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli()); + pHeli->ClearHeliOrientation(); return 0; } case COMMAND_PLANE_GOTO_COORDS: @@ -10879,9 +10888,10 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_POP_CAR_BOOT: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - debug("POP_CAR_BOOT is not implemented\n"); // TODO(MIAMI) + CollectParameters(&m_nIp, 1); + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(pCar&& pCar->IsCar()); + pCar->PopBoot(); return 0; } case COMMAND_SHUT_PLAYER_UP: @@ -11143,7 +11153,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_CREATE_SWAT_ROPE: { CollectParameters(&m_nIp, 3); - debug("SET_CHAR_OBJ_SPRINT_TO_COORD is not implemented\n"); + debug("CREATE_SWAT_ROPE is not implemented\n"); return 0; } //case COMMAND_SET_FIRST_PERSON_CONTROL_CAMERA: @@ -11163,7 +11173,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_CLOSE_ALL_CAR_DOORS: { CollectParameters(&m_nIp, 1); - debug("CLOSE_ALL_CAR_DOORS is not implemented\n"); // TODO(MIAMI) + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(pCar&& pCar->IsCar()); + pCar->CloseAllDoors(); return 0; } case COMMAND_GET_DISTANCE_BETWEEN_COORDS_2D: @@ -11183,7 +11195,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_POP_CAR_BOOT_USING_PHYSICS: { CollectParameters(&m_nIp, 1); - debug("POP_CAR_BOOT_USING_PHYSICS is not implemented\n"); // TODO(MIAMI) + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(pCar && pCar->IsCar()); + pCar->PopBootUsingPhysics(); return 0; } //case COMMAND_SET_FIRST_PERSON_WEAPON_CAMERA: @@ -11727,7 +11741,9 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_MAKE_HELI_COME_CRASHING_DOWN: { CollectParameters(&m_nIp, 1); - debug("MAKE_HELI_COME_CRASHING_DOWN is not implemented\n"); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli()); + pHeli->bHeliDestroyed = true; return 0; } case COMMAND_ADD_EXPLOSION_NO_SOUND: @@ -11775,18 +11791,18 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - debug("SET_CHAR_CROUCH_WHEN_THREATENED not implemented, skipping\n"); + assert(pPed); + pPed->bCrouchWhenScared = true; return 0; } case COMMAND_IS_CHAR_IN_ANY_POLICE_VEHICLE: { CollectParameters(&m_nIp, 1); - static bool bShowed = false; - if (!bShowed) { - debug("IS_CHAR_IN_ANY_POLICE_VEHICLE not implemented, default to FALSE\n"); - bShowed = true; - } - UpdateCompareFlag(false); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(pPed); + UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle && + pPed->m_pMyVehicle->IsLawEnforcementVehicle() && + pPed->m_pMyVehicle->GetModelIndex() != MI_PREDATOR); return 0; } case COMMAND_DOES_CHAR_EXIST: @@ -11817,7 +11833,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_ALL_TAXIS_HAVE_NITRO: { CollectParameters(&m_nIp, 1); - debug("SET_ALL_TAXIS_HAVE_NITRO is not implemented\n"); // TODO(MIAMI) + CVehicle::bAllTaxisHaveNitro = ScriptParams[0] != 0; return 0; } case COMMAND_SET_CHAR_STOP_SHOOT_DONT_SEEK_ENTITY: @@ -11914,7 +11930,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_PLAY_ANNOUNCEMENT: { CollectParameters(&m_nIp, 1); - debug("PLAY_ANNOUNCEMENT not implemented, skipping\n"); + DMAudio.PlayRadioAnnouncement(ScriptParams[0] + STREAMED_SOUND_ANNOUNCE_BRIDGE_CLOSED); return 0; } case COMMAND_SET_PLAYER_IS_IN_STADIUM: diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index 090eae6b..12345cc9 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -1610,7 +1610,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) A->bSkipLineCol = true; }else if(A->IsPed() && Aped->m_pCollidingEntity == B){ skipCollision = true; - if(!Aped->bKnockedUpIntoAir || Aped->b158_4) + if(!Aped->bKnockedUpIntoAir || Aped->bKnockedOffBike) A->bSkipLineCol = true; }else if(B->IsPed() && Bped->m_pCollidingEntity == A){ skipCollision = true; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 961b8f61..744ba793 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -3770,7 +3770,8 @@ CPed::ClearAll(void) bIsPointingGunAt = false; bRenderPedInCar = true; bKnockedUpIntoAir = false; - b158_4 = false; + bCrouchWhenScared = false; + bKnockedOffBike = false; m_pCollidingEntity = nil; } @@ -7054,7 +7055,7 @@ CPed::Fall(void) CAnimBlendAssociation *firstPartialAssoc; CAnimBlendAssociation *fallAssoc; - if (IsPlayer() && (bKnockedUpIntoAir || b158_4) && !bIsStanding) { + if (IsPlayer() && (bKnockedUpIntoAir || bKnockedOffBike) && !bIsStanding) { firstPartialAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_PARTIAL); // What??? @@ -7082,7 +7083,7 @@ CPed::Fall(void) } else { CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FALL_BACK, 8.0f); } - } else if ((bKnockedUpIntoAir || b158_4) && bIsStanding && !bWasStanding) { + } else if ((bKnockedUpIntoAir || bKnockedOffBike) && bIsStanding && !bWasStanding) { fallAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_BACK); if (!fallAssoc) @@ -7090,7 +7091,7 @@ CPed::Fall(void) if (fallAssoc) { bKnockedUpIntoAir = false; - b158_4 = false; + bKnockedOffBike = false; fallAssoc->speed = 3.0f; if (IsPlayer()) Say(SOUND_PED_LAND); @@ -7099,7 +7100,7 @@ CPed::Fall(void) firstPartialAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_PARTIAL); if (firstPartialAssoc && !firstPartialAssoc->IsRunning()) { bKnockedUpIntoAir = false; - b158_4 = false; + bKnockedOffBike = false; } } } diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 8aead855..673c70b0 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -473,8 +473,8 @@ public: uint32 bIgnoreThreatsBehindObjects : 1; uint32 bNeverEverTargetThisPed : 1; - //uint32 b158_2 - uint32 b158_4 : 1; + uint32 bCrouchWhenScared : 1; + uint32 bKnockedOffBike : 1; //uint32 b158_8 //uint32 b158_10 uint32 bBoughtIceCream : 1; diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index 314d8e00..74dd376b 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -2685,7 +2685,7 @@ CBike::KnockOffRider(eWeaponType weapon, uint8 direction, CPed *ped, bool bGetBa case 3: anim = ANIM_KD_LEFT; break; } if(m_nWheelsOnGround == 0) - ped->b158_4 = true; + ped->bKnockedOffBike = true; break; } @@ -2703,7 +2703,7 @@ CBike::KnockOffRider(eWeaponType weapon, uint8 direction, CPed *ped, bool bGetBa case 2: anim = ANIM_KO_SKID_FRONT; break; case 3: anim = ANIM_KD_LEFT; break; } - ped->b158_4 = true; + ped->bKnockedOffBike = true; if(ped->IsPlayer()) ped->Say(SOUND_PED_DAMAGE); break; @@ -2745,7 +2745,7 @@ CBike::KnockOffRider(eWeaponType weapon, uint8 direction, CPed *ped, bool bGetBa }else ped->GetMatrix().Translate(CVector(0.0f, 0.0f, -2.0f)); ped->m_pCollidingEntity = ped->m_pMyVehicle; - ped->b158_4 = true; + ped->bKnockedOffBike = true; ped->bHeadStuckInCollision = true; }else if(weapon == WEAPONTYPE_RAMMEDBYCAR){ if(CWorld::TestSphereAgainstWorld(ped->GetPosition()+CVector(0.0f, 0.0, 1.3f), 0.6f, nil, true, false, false, false, false, false) == nil)