summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/control')
-rw-r--r--src/control/Pickups.cpp87
-rw-r--r--src/control/Script.cpp94
-rw-r--r--src/control/Script.h7
3 files changed, 139 insertions, 49 deletions
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp
index 1ab09d52..95abe2c5 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -71,11 +71,6 @@ uint8 aWeaponBlues[] = { 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 128, 255, 0, 0 };
-float aWeaponScale[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
-2.0f, 1.5f, 1.0f, 1.0f, 1.5f, 1.0f, 2.0f, 1.0f, 2.0f, 2.5f, 1.0f,
-1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f, 1.0f };
-
void
CPickup::RemoveKeepType()
{
@@ -699,41 +694,51 @@ CPickups::DoPickUpEffects(CEntity *entity)
int16 colorId;
+ bool doInnerGlow = false;
+ bool doOuterGlow = true;
- if (entity->GetModelIndex() == MI_PICKUP_ADRENALINE || entity->GetModelIndex() == MI_PICKUP_CAMERA)
+ if (entity->GetModelIndex() == MI_PICKUP_ADRENALINE || entity->GetModelIndex() == MI_PICKUP_CAMERA) {
colorId = WEAPONTYPE_TOTALWEAPONS;
- else if (entity->GetModelIndex() == MI_PICKUP_BODYARMOUR || entity->GetModelIndex() == MI_PICKUP_BRIBE)
+ doInnerGlow = true;
+ doOuterGlow = false;
+ } else if (entity->GetModelIndex() == MI_PICKUP_BODYARMOUR) {
colorId = WEAPONTYPE_TOTALWEAPONS + 1;
- else if (entity->GetModelIndex() == MI_PICKUP_INFO || entity->GetModelIndex() == MI_PICKUP_KILLFRENZY)
+ } else if (entity->GetModelIndex() == MI_PICKUP_BRIBE) {
+ doInnerGlow = true;
+ doOuterGlow = false;
+ } else if (entity->GetModelIndex() == MI_PICKUP_INFO || entity->GetModelIndex() == MI_PICKUP_KILLFRENZY) {
colorId = WEAPONTYPE_TOTALWEAPONS + 2;
- else if (entity->GetModelIndex() == MI_PICKUP_HEALTH || entity->GetModelIndex() == MI_PICKUP_BONUS)
- colorId = WEAPONTYPE_TOTALWEAPONS + 3;
- else
+ doInnerGlow = true;
+ doOuterGlow = false;
+ } else if (entity->GetModelIndex() == MI_PICKUP_HEALTH || entity->GetModelIndex() == MI_PICKUP_BONUS) {
+ colorId = WEAPONTYPE_TOTALWEAPONS;
+ doInnerGlow = true;
+ doOuterGlow = false;
+ } else
colorId = WeaponForModel(entity->GetModelIndex());
- assert(colorId >= 0);
-
- const CVector &pos = entity->GetPosition();
-
- float colorModifier = ((CGeneral::GetRandomNumber() & 0x1F) * 0.015f + 1.0f) * modifiedSin * 0.15f;
- CShadows::StoreStaticShadow(
- (uintptr)entity,
- SHADOWTYPE_ADDITIVE,
- gpShadowExplosionTex,
- &pos,
- 2.0f, 0.0f, 0.0f, -2.0f,
- 255, // this is 0 on PC which results in no shadow
- aWeaponReds[colorId] * colorModifier, aWeaponGreens[colorId] * colorModifier, aWeaponBlues[colorId] * colorModifier,
- 4.0f, 1.0f, 40.0f, false, 0.0f);
-
- float radius = (CGeneral::GetRandomNumber() & 0xF) * 0.1f + 3.0f;
- CPointLights::AddLight(CPointLights::LIGHT_POINT, pos, CVector(0.0f, 0.0f, 0.0f), radius, aWeaponReds[colorId] * modifiedSin / 256.0f, aWeaponGreens[colorId] * modifiedSin / 256.0f, aWeaponBlues[colorId] * modifiedSin / 256.0f, CPointLights::FOG_NONE, true);
- float size = (CGeneral::GetRandomNumber() & 0xF) * 0.0005f + 0.6f;
- CCoronas::RegisterCorona( (uintptr)entity,
- aWeaponReds[colorId] * modifiedSin / 2.0f, aWeaponGreens[colorId] * modifiedSin / 2.0f, aWeaponBlues[colorId] * modifiedSin / 2.0f,
- 255,
- pos,
- size, 65.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
+ const CVector& pos = entity->GetPosition();
+ if (doOuterGlow) {
+ float colorModifier = ((CGeneral::GetRandomNumber() & 0x1F) * 0.015f + 1.0f) * modifiedSin * 0.15f;
+ CShadows::StoreStaticShadow(
+ (uintptr)entity,
+ SHADOWTYPE_ADDITIVE,
+ gpShadowExplosionTex,
+ &pos,
+ 2.0f, 0.0f, 0.0f, -2.0f,
+ 255, // this is 0 on PC which results in no shadow
+ aWeaponReds[colorId] * colorModifier, aWeaponGreens[colorId] * colorModifier, aWeaponBlues[colorId] * colorModifier,
+ 4.0f, 1.0f, 40.0f, false, 0.0f);
+
+ float radius = (CGeneral::GetRandomNumber() & 0xF) * 0.1f + 3.0f;
+ CPointLights::AddLight(CPointLights::LIGHT_POINT, pos, CVector(0.0f, 0.0f, 0.0f), radius, aWeaponReds[colorId] * modifiedSin / 256.0f, aWeaponGreens[colorId] * modifiedSin / 256.0f, aWeaponBlues[colorId] * modifiedSin / 256.0f, CPointLights::FOG_NONE, true);
+ float size = (CGeneral::GetRandomNumber() & 0xF) * 0.0005f + 0.6f;
+ CCoronas::RegisterCorona((uintptr)entity,
+ aWeaponReds[colorId] * modifiedSin / 2.0f, aWeaponGreens[colorId] * modifiedSin / 2.0f, aWeaponBlues[colorId] * modifiedSin / 2.0f,
+ 255,
+ pos,
+ size, 65.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f);
+ }
CObject *object = (CObject*)entity;
if (object->bPickupObjWithMessage || object->bOutOfStock || object->m_nBonusValue) {
@@ -760,7 +765,19 @@ CPickups::DoPickUpEffects(CEntity *entity)
}
}
- entity->GetMatrix().SetRotateZOnlyScaled((float)(CTimer::GetTimeInMilliseconds() & 0x7FF) * DEGTORAD(360.0f / 0x800), aWeaponScale[colorId]);
+ uint32 model = entity->GetModelIndex();
+ CColModel* colModel = entity->GetColModel();
+ CVector colLength = colModel->boundingBox.max - colModel->boundingBox.min;
+
+ float scale = (Max(1.f, 1.2f / Max(colLength.x, Max(colLength.y, colLength.z))) - 1.0f) * 0.6f + 1.0f;
+ if (model == MI_MINIGUN || model == MI_MINIGUN2)
+ scale = 1.2f;
+
+ entity->GetMatrix().SetRotateZOnlyScaled((float)(CTimer::GetTimeInMilliseconds() & 0x7FF) * DEGTORAD(360.0f / 0x800), scale);
+
+ if (doInnerGlow)
+ CCoronas::RegisterCorona((uintptr)entity + 1, 126, 69, 121, 255, entity->GetPosition(), 1.2f, 50.0f,
+ CCoronas::TYPE_STAR, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.f, false);
}
}
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index ec2dea87..b1cf44c6 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -166,7 +166,6 @@ bool doingMissionRetry;
#endif
-
const uint32 CRunningScript::nSaveStructSize =
#ifdef COMPATIBLE_SAVES
136;
@@ -2032,7 +2031,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
ped->ClearAll();
int8 path = ScriptParams[1];
if (ScriptParams[1] < 0 || ScriptParams[1] > 7)
+ // Max number GetRandomNumberInRange returns is max-1
+#ifdef FIX_BUGS
+ path = CGeneral::GetRandomNumberInRange(0, 8);
+#else
path = CGeneral::GetRandomNumberInRange(0, 7);
+#endif
+
ped->SetWanderPath(path);
return 0;
}
@@ -2051,10 +2056,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
eMoveState state;
switch (ScriptParams[5]) {
case 0: state = PEDMOVE_WALK; break;
- case 1: state = PEDMOVE_SPRINT; break;
+ case 1: state = PEDMOVE_RUN; break;
default: assert(0);
}
ped->ClearAll();
+ ped->m_pathNodeTimer = 0;
ped->SetFollowPath(pos, radius, state, nil, nil, 999999);
return 0;
}
@@ -9126,6 +9132,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
case COMMAND_LOAD_AND_LAUNCH_MISSION_INTERNAL:
{
CollectParameters(&m_nIp, 1);
+
if (CTheScripts::NumberOfExclusiveMissionScripts > 0 && ScriptParams[0] <= UINT16_MAX - 2)
return 0;
#ifdef MISSION_REPLAY
@@ -9989,7 +9996,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
continue;
if (pPed->CharCreatedBy != RANDOM_CHAR)
continue;
- if (!pPed->IsPedInControl() && pPed->GetPedState() != PED_DRIVING /* && pPed->GetPedState() != PED_ONROPE */) // TODO(MIAMI)!
+ if (!pPed->IsPedInControl() && pPed->GetPedState() != PED_DRIVING && pPed->GetPedState() != PED_ABSEIL)
continue;
if (pPed->bRemoveFromWorld)
continue;
@@ -10633,7 +10640,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
char key[KEY_LENGTH_IN_SCRIPT];
CTheScripts::ReadTextLabelFromScript(&m_nIp, key);
m_nIp += KEY_LENGTH_IN_SCRIPT;
- debug("SET_CUTSCENE_ANIM_TO_LOOP not implemented yet, skipping\n");
+ CCutsceneMgr::SetCutsceneAnimToLoop(key);
return 0;
}
case COMMAND_MARK_CAR_AS_CONVOY_CAR:
@@ -10676,7 +10683,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]);
assert(pTargetPed);
pPed->bScriptObjectiveCompleted = false;
- pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING, pPed);
+ pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING, pTargetPed);
return 0;
}
//case COMMAND_IS_PICKUP_IN_ZONE:
@@ -11332,6 +11339,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
debug("ATTACH_CUTSCENE_OBJECT_TO_COMPONENT not implemented, skipping\n"); // TODO(MIAMI)
+ m_nIp += KEY_LENGTH_IN_SCRIPT;
return 0;
}
case COMMAND_SET_CHAR_STAY_IN_CAR_WHEN_JACKED:
@@ -11457,7 +11465,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
case COMMAND_FIRE_HUNTER_GUN:
{
CollectParameters(&m_nIp, 1);
- debug("FIRE_HUNTER_GUN is not implemented, skipping\n"); // TODO(MIAMI)
+ CVehicle *pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nGunFiringTime + 150) {
+ CWeapon gun(WEAPONTYPE_HELICANNON, 5000);
+ CVector worldGunPos = (pVehicle->GetMatrix() * vecHunterGunPos) + (CTimer::GetTimeStep() * pVehicle->m_vecMoveSpeed);
+ gun.FireInstantHit(pVehicle, &worldGunPos);
+ gun.AddGunshell(pVehicle, worldGunPos, CVector2D(0.f, 0.1f), 0.025f);
+ DMAudio.PlayOneShot(pVehicle->m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.f);
+ pVehicle->m_nGunFiringTime = CTimer::GetTimeInMilliseconds();
+ }
return 0;
}
case COMMAND_SET_PROPERTY_AS_OWNED:
@@ -11697,7 +11713,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
case COMMAND_SET_CHAR_IGNORE_THREATS_BEHIND_OBJECTS:
{
CollectParameters(&m_nIp, 2);
- CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
pPed->bIgnoreThreatsBehindObjects = ScriptParams[1];
return 0;
@@ -11762,12 +11778,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
}
case COMMAND_WAS_CUTSCENE_SKIPPED:
{
- static bool bShowed = false;
- if (!bShowed) {
- debug("COMMAND_WAS_CUTSCENE_SKIPPED not implemented, default to TRUE\n");
- bShowed = true;
- }
- UpdateCompareFlag(true);
+ UpdateCompareFlag(CCutsceneMgr::WasCutsceneSkipped());
return 0;
}
case COMMAND_SET_CHAR_CROUCH_WHEN_THREATENED:
@@ -14220,7 +14231,7 @@ void CTheScripts::CleanUpThisPed(CPed* pPed)
pPed->CharCreatedBy = RANDOM_CHAR;
if (pPed->m_nPedType == PEDTYPE_PROSTITUTE)
pPed->m_objectiveTimer = CTimer::GetTimeInMilliseconds() + 30000;
- if (pPed->bInVehicle) {
+ if (pPed->InVehicle()) {
if (pPed->m_pMyVehicle->pDriver == pPed) {
if (pPed->m_pMyVehicle->m_vehType == VEHICLE_TYPE_CAR) {
CCarCtrl::JoinCarWithRoadSystem(pPed->m_pMyVehicle);
@@ -14245,10 +14256,14 @@ void CTheScripts::CleanUpThisPed(CPed* pPed)
pPed->ClearObjective();
pPed->bRespondsToThreats = true;
pPed->bScriptObjectiveCompleted = false;
+ pPed->bKindaStayInSamePlace = false;
pPed->ClearLeader();
if (pPed->IsPedInControl())
pPed->SetWanderPath(CGeneral::GetRandomNumber() & 7);
if (flees) {
+ if (pPed->m_nPedState == PED_FOLLOW_PATH && state != PED_FOLLOW_PATH)
+ pPed->ClearFollowPath();
+
pPed->m_nPedState = state;
pPed->SetMoveState(ms);
}
@@ -14451,3 +14466,54 @@ void RetryMission(int type, int unk)
}
#endif
+
+#ifdef MISSION_SWITCHER
+void
+CTheScripts::SwitchToMission(int32 mission)
+{
+ for (CRunningScript* pScript = CTheScripts::pActiveScripts; pScript != nil; pScript = pScript->GetNext()) {
+ if (!pScript->m_bIsMissionScript || !pScript->m_bDeatharrestEnabled) {
+ continue;
+ }
+ while (pScript->m_nStackPointer > 0)
+ --pScript->m_nStackPointer;
+
+ pScript->m_nIp = pScript->m_anStack[pScript->m_nStackPointer];
+ *(int32*)&CTheScripts::ScriptSpace[CTheScripts::OnAMissionFlag] = 0;
+ pScript->m_nWakeTime = 0;
+ pScript->m_bDeatharrestExecuted = true;
+
+ while (!pScript->ProcessOneCommand());
+
+ CMessages::ClearMessages();
+ }
+
+ if (CTheScripts::NumberOfExclusiveMissionScripts > 0 && mission <= UINT16_MAX - 2)
+ return;
+
+#ifdef MISSION_REPLAY
+ missionRetryScriptIndex = mission;
+ if (missionRetryScriptIndex == 19)
+ CStats::LastMissionPassedName[0] = '\0';
+#endif
+ CTimer::Suspend();
+ int offset = CTheScripts::MultiScriptArray[mission];
+#ifdef USE_DEBUG_SCRIPT_LOADER
+ CFileMgr::ChangeDir("\\data\\");
+ int handle = CFileMgr::OpenFile(scriptfile, "rb");
+ CFileMgr::ChangeDir("\\");
+#else
+ CFileMgr::ChangeDir("\\");
+ int handle = CFileMgr::OpenFile("data\\main.scm", "rb");
+#endif
+ CFileMgr::Seek(handle, offset, 0);
+ CFileMgr::Read(handle, (const char*)&CTheScripts::ScriptSpace[SIZE_MAIN_SCRIPT], SIZE_MISSION_SCRIPT);
+ CFileMgr::CloseFile(handle);
+ CRunningScript* pMissionScript = CTheScripts::StartNewScript(SIZE_MAIN_SCRIPT);
+ CTimer::Resume();
+ pMissionScript->m_bIsMissionScript = true;
+ pMissionScript->m_bMissionFlag = true;
+ CTheScripts::bAlreadyRunningAMissionScript = true;
+ CGameLogic::ClearShortCut();
+}
+#endif \ No newline at end of file
diff --git a/src/control/Script.h b/src/control/Script.h
index 3044e770..9b2de580 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -375,6 +375,11 @@ private:
static void RemoveScriptTextureDictionary();
static void RemoveThisPed(CPed* pPed);
+#ifdef MISSION_SWITCHER
+public:
+ static void SwitchToMission(int32 mission);
+#endif
+
friend class CRunningScript;
friend class CHud;
friend void CMissionCleanup::Process();
@@ -526,6 +531,8 @@ private:
bool CheckDamagedWeaponType(int32 actual, int32 type);
static bool ThisIsAValidRandomCop(int32 mi, bool cop, bool swat, bool fbi, bool army, bool miami);
+
+ friend class CTheScripts;
};
#ifdef USE_DEBUG_SCRIPT_LOADER