2020-12-28 09:51:40 +01:00
|
|
|
#include "driver2.h"
|
|
|
|
#include "pedest.h"
|
|
|
|
#include "players.h"
|
|
|
|
#include "mission.h"
|
|
|
|
#include "objcoll.h"
|
|
|
|
#include "cosmetic.h"
|
|
|
|
#include "models.h"
|
|
|
|
#include "dr2roads.h"
|
|
|
|
#include "motion_c.h"
|
|
|
|
#include "convert.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "pad.h"
|
|
|
|
#include "civ_ai.h"
|
|
|
|
#include "glaunch.h"
|
|
|
|
#include "cutscene.h"
|
|
|
|
#include "camera.h"
|
|
|
|
#include "pause.h"
|
|
|
|
#include "ai.h"
|
|
|
|
#include "cars.h"
|
|
|
|
#include "felony.h"
|
|
|
|
#include "job_fx.h"
|
|
|
|
#include "bcollide.h"
|
|
|
|
#include "gamesnd.h"
|
|
|
|
#include "map.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "handling.h"
|
2020-05-24 10:22:31 +02:00
|
|
|
|
2020-12-28 09:51:40 +01:00
|
|
|
#include "ASM/rndrasm.h"
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-05-15 10:12:13 +02:00
|
|
|
MODEL* pmTannerModels[17] = { 0 };
|
2020-05-23 16:36:40 +02:00
|
|
|
MODEL* pmJerichoModels[6] = { 0 };
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
void PedDoNothing(PEDESTRIAN* pPed);
|
|
|
|
void PedUserWalker(PEDESTRIAN* pPed);
|
|
|
|
void PedUserRunner(PEDESTRIAN* pPed);
|
|
|
|
void PedGetInCar(PEDESTRIAN* pPed);
|
|
|
|
void PedGetOutCar(PEDESTRIAN* pPed);
|
|
|
|
void PedCarryOutAnimation(PEDESTRIAN* pPed);
|
|
|
|
void CivPedDoNothing(PEDESTRIAN* pPed);
|
|
|
|
void CivPedWalk(PEDESTRIAN* pPed);
|
|
|
|
void CivPedSit(PEDESTRIAN* pPed);
|
|
|
|
void CivPedJump(PEDESTRIAN* pPed);
|
|
|
|
void PedPressButton(PEDESTRIAN* pPed);
|
|
|
|
void TannerSitDown(PEDESTRIAN* pPed);
|
|
|
|
void CopStand(PEDESTRIAN* pPed);
|
|
|
|
void CivGetIn(PEDESTRIAN* pPed);
|
2020-03-27 21:47:29 +01:00
|
|
|
|
|
|
|
pedFunc fpPedPersonalityFunctions[] = {
|
2020-09-04 20:58:59 +02:00
|
|
|
PedDoNothing,
|
|
|
|
PedUserWalker,
|
|
|
|
PedUserRunner,
|
|
|
|
PedGetInCar,
|
|
|
|
PedGetOutCar,
|
2020-03-27 21:47:29 +01:00
|
|
|
PedCarryOutAnimation,
|
2020-09-04 20:58:59 +02:00
|
|
|
|
|
|
|
CivPedDoNothing,
|
|
|
|
CivPedWalk,
|
|
|
|
CivPedSit,
|
|
|
|
CivPedJump,
|
|
|
|
|
|
|
|
PedPressButton,
|
|
|
|
TannerSitDown,
|
|
|
|
|
|
|
|
CopStand,
|
|
|
|
CivGetIn,
|
2020-05-15 10:12:13 +02:00
|
|
|
};
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-11-14 22:26:36 +01:00
|
|
|
SVECTOR tannerLookAngle = { 0, 0, 0, 0 };
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
const int tannerTurnMax = 16;
|
|
|
|
const int tannerTurnStep = 4;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-04-28 20:00:25 +02:00
|
|
|
int bKillTanner = 0;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
SEATED_PEDESTRIANS* seated_pedestrian; // lump
|
2020-05-15 10:12:13 +02:00
|
|
|
int seated_count;
|
|
|
|
int maxSeated;
|
|
|
|
static int numTannerPeds = 0;
|
|
|
|
static int numCopPeds = 0;
|
|
|
|
int pinginPedAngle = 0;
|
|
|
|
|
2020-09-04 20:58:59 +02:00
|
|
|
PEDESTRIAN pedestrians[MAX_PEDESTRIANS];
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* pUsedPeds = NULL; // linked list of pedestrians
|
|
|
|
PEDESTRIAN* pFreePeds = NULL;
|
|
|
|
PEDESTRIAN* pHold = NULL;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
|
|
|
int max_pedestrians;
|
|
|
|
int num_pedestrians;
|
|
|
|
|
|
|
|
char ping_in_pedestrians = 0;
|
|
|
|
|
|
|
|
int bKilled = 0;
|
|
|
|
|
2020-05-15 12:33:29 +02:00
|
|
|
PEDESTRIAN_ROADS pedestrian_roads;
|
|
|
|
|
2020-12-08 17:45:14 +01:00
|
|
|
u_int tannerPad;
|
2020-05-15 13:38:32 +02:00
|
|
|
extern short padd;
|
|
|
|
SVECTOR camAngle;
|
|
|
|
static int oldCamView;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-05-15 13:16:18 +02:00
|
|
|
int bPower = 0;
|
|
|
|
int oldWeather = 0;
|
|
|
|
int powerCounter = 0;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void InitTanner(void)
|
|
|
|
{
|
2020-05-23 16:36:40 +02:00
|
|
|
pmTannerModels[0] = FindModelPtrWithName("TORSO");
|
|
|
|
pmTannerModels[1] = FindModelPtrWithName("HEAD");
|
|
|
|
pmTannerModels[2] = FindModelPtrWithName("U_ARM_RIGHT");
|
|
|
|
pmTannerModels[3] = FindModelPtrWithName("L_ARM_RIGHT");
|
|
|
|
pmTannerModels[4] = FindModelPtrWithName("HAND_RIGHT");
|
|
|
|
pmTannerModels[5] = FindModelPtrWithName("THIGH_RIGHT");
|
|
|
|
pmTannerModels[6] = FindModelPtrWithName("CALF_RIGHT");
|
|
|
|
pmTannerModels[7] = FindModelPtrWithName("FOOT_LEFT");
|
|
|
|
pmTannerModels[8] = FindModelPtrWithName("U_ARM_LEFT");
|
|
|
|
pmTannerModels[9] = FindModelPtrWithName("L_ARM_LEFT");
|
|
|
|
pmTannerModels[10] = FindModelPtrWithName("HAND_LEFT");
|
|
|
|
pmTannerModels[11] = FindModelPtrWithName("THIGH_LEFT");
|
|
|
|
pmTannerModels[12] = FindModelPtrWithName("CALF_LEFT");
|
|
|
|
pmTannerModels[13] = FindModelPtrWithName("FOOT_RIGHT");
|
|
|
|
pmTannerModels[14] = FindModelPtrWithName("NECK");
|
|
|
|
pmTannerModels[15] = FindModelPtrWithName("HIPS");
|
|
|
|
pmTannerModels[16] = FindModelPtrWithName("BAG");
|
|
|
|
|
|
|
|
pmJerichoModels[0] = FindModelPtrWithName("JERI_TORSO");
|
|
|
|
pmJerichoModels[1] = FindModelPtrWithName("JERI_HEAD");
|
|
|
|
pmJerichoModels[2] = FindModelPtrWithName("JERI_U_ARM_LEFT");
|
|
|
|
pmJerichoModels[3] = FindModelPtrWithName("JERI_L_ARM_LEFT");
|
|
|
|
pmJerichoModels[4] = FindModelPtrWithName("JERI_U_ARM_RIGHT");
|
|
|
|
pmJerichoModels[5] = FindModelPtrWithName("JERI_L_ARM_RIGHT");
|
|
|
|
|
2020-06-21 10:49:50 +02:00
|
|
|
SetSkelModelPointers(TANNER_MODEL);
|
2020-04-03 00:44:09 +02:00
|
|
|
StoreVertexLists();
|
2020-05-23 16:36:40 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
numTannerPeds = 0;
|
|
|
|
bKillTanner = 0;
|
|
|
|
bKilled = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void SetTannerPosition(VECTOR* pVec)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* pPed;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
|
|
|
pPed = pUsedPeds;
|
2020-10-11 12:19:12 +02:00
|
|
|
while (pPed)
|
2020-05-15 10:12:13 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->pedType == TANNER_MODEL || ActiveCheats.cheat12 && pPed->pedType == OTHER_MODEL)
|
2020-05-15 10:12:13 +02:00
|
|
|
{
|
|
|
|
pPed->position.vx = pVec->vx;
|
|
|
|
pPed->position.vy = -pVec->vy;
|
|
|
|
pPed->position.vz = pVec->vz;
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-05-15 10:12:13 +02:00
|
|
|
player[0].pos[0] = pVec->vx;
|
|
|
|
player[0].pos[1] = pVec->vy;
|
|
|
|
player[0].pos[2] = pVec->vz;
|
|
|
|
}
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-05-15 10:12:13 +02:00
|
|
|
pPed = pPed->pNext;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void InitPedestrians(void)
|
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
int loop;
|
|
|
|
SEATED_PEDESTRIANS* seatedptr;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-12-28 11:07:24 +01:00
|
|
|
memset((u_char*)pedestrians, 0, sizeof(pedestrians));
|
2020-04-03 00:44:09 +02:00
|
|
|
DestroyPedestrians();
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* lastPed = &pedestrians[0];
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-09-04 20:58:59 +02:00
|
|
|
lastPed->pPrev = NULL;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
for (loop = 1; loop < MAX_PEDESTRIANS; loop++)
|
2020-09-04 20:58:59 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* currPed = &pedestrians[loop];
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-09-04 20:58:59 +02:00
|
|
|
lastPed->pNext = currPed;
|
|
|
|
currPed->pPrev = lastPed++;
|
|
|
|
}
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-09-04 20:58:59 +02:00
|
|
|
lastPed->pNext = NULL;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-09-04 20:58:59 +02:00
|
|
|
pUsedPeds = NULL;
|
2020-05-15 10:12:13 +02:00
|
|
|
pFreePeds = pedestrians;
|
2020-09-04 20:58:59 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
seated_count = 0;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
|
|
|
seatedptr = seated_pedestrian;
|
2020-10-11 12:19:12 +02:00
|
|
|
if (seatedptr != NULL)
|
2020-05-15 10:12:13 +02:00
|
|
|
{
|
2020-09-04 20:58:59 +02:00
|
|
|
while (seatedptr->rotation != 9999)
|
2020-05-15 10:12:13 +02:00
|
|
|
{
|
|
|
|
seatedptr->index = 0;
|
|
|
|
|
|
|
|
seated_count++;
|
|
|
|
seatedptr++;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
maxSeated = seated_count;
|
|
|
|
numTannerPeds = 0;
|
|
|
|
pinginPedAngle = 0;
|
2020-05-15 10:12:13 +02:00
|
|
|
pPlayerPed = NULL;
|
2020-04-03 00:44:09 +02:00
|
|
|
seated_count = 0;
|
2020-05-15 10:12:13 +02:00
|
|
|
ping_in_pedestrians = 1;
|
2020-10-11 12:19:12 +02:00
|
|
|
numCopPeds = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DestroyPedestrians(void)
|
|
|
|
{
|
2020-05-15 10:12:13 +02:00
|
|
|
while (pUsedPeds)
|
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pUsedPeds->pedType == TANNER_MODEL || ActiveCheats.cheat12 && pUsedPeds->pedType == OTHER_MODEL)
|
2020-05-15 10:12:13 +02:00
|
|
|
numTannerPeds--;
|
|
|
|
|
|
|
|
DestroyPedestrian(pUsedPeds);
|
2020-10-11 12:19:12 +02:00
|
|
|
}
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
num_pedestrians = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DestroyCivPedestrians(void)
|
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* pPed;
|
|
|
|
PEDESTRIAN* pHPed;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-05-24 16:12:10 +02:00
|
|
|
pPed = pUsedPeds;
|
|
|
|
while (pPed != NULL)
|
|
|
|
{
|
|
|
|
pHPed = pPed->pNext;
|
|
|
|
|
|
|
|
if (pPed->pedType == CIVILIAN)
|
|
|
|
{
|
|
|
|
DestroyPedestrian(pUsedPeds);
|
|
|
|
num_pedestrians--;
|
|
|
|
}
|
|
|
|
|
|
|
|
pPed = pHPed;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void DestroyPedestrian(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->flags & 8)
|
|
|
|
numCopPeds--; // or road block pedestrians
|
2020-04-03 00:44:09 +02:00
|
|
|
|
|
|
|
pPed->flags = 0;
|
2020-05-15 10:12:13 +02:00
|
|
|
pPed->dir.vz = 0;
|
|
|
|
pPed->dir.vy = 0;
|
|
|
|
pPed->dir.vx = 0;
|
|
|
|
|
|
|
|
if (pPed == pUsedPeds)
|
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pUsedPeds = pPed->pNext;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pUsedPeds) // [A] is this valid? Or it was by Reflections?
|
2020-05-15 10:12:13 +02:00
|
|
|
pUsedPeds->pPrev = NULL;
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->pNext = pFreePeds;
|
2020-06-21 10:49:50 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pFreePeds)
|
2020-06-21 10:49:50 +02:00
|
|
|
pFreePeds->pPrev = pPed;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 10:12:13 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->pPrev)
|
2020-08-30 16:50:31 +02:00
|
|
|
pPed->pPrev->pNext = pPed->pNext;
|
|
|
|
|
2020-05-15 10:12:13 +02:00
|
|
|
if (pPed->pNext)
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->pNext->pPrev = pPed->pPrev;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->pNext = pFreePeds;
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pFreePeds)
|
2020-06-21 10:49:50 +02:00
|
|
|
pFreePeds->pPrev = pPed;
|
2020-05-15 10:12:13 +02:00
|
|
|
pPed->pPrev = NULL;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pFreePeds = pPed;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
|
|
|
if (pPed->type == PED_ACTION_CIVSIT)
|
|
|
|
seated_pedestrian[pPed->seat_index].index = 0; // [A] removed check
|
|
|
|
|
|
|
|
pPed->doing_turn = 0;
|
|
|
|
|
|
|
|
num_pedestrians--;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-12-09 09:33:57 +01:00
|
|
|
int PedSurfaceType(VECTOR* ped_pos)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-12-09 09:33:57 +01:00
|
|
|
sdPlane* sfc_ptr;
|
|
|
|
sfc_ptr = sdGetCell(ped_pos);
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
if (!sfc_ptr)
|
2020-06-22 19:50:29 +02:00
|
|
|
return 0;
|
2020-05-15 10:12:13 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
return sfc_ptr->surface;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
PEDESTRIAN* CreatePedestrian(void)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* pNewPed;
|
2020-05-15 10:12:13 +02:00
|
|
|
pNewPed = pFreePeds;
|
|
|
|
|
|
|
|
if (pFreePeds != NULL)
|
|
|
|
{
|
|
|
|
if (pFreePeds->pNext != NULL)
|
|
|
|
pFreePeds->pNext->pPrev = NULL;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
|
|
|
pFreePeds = pFreePeds->pNext;
|
2020-05-15 10:12:13 +02:00
|
|
|
if (pUsedPeds != NULL)
|
|
|
|
pUsedPeds->pPrev = pNewPed;
|
|
|
|
|
|
|
|
pNewPed->pPrev = NULL;
|
|
|
|
pNewPed->pNext = pUsedPeds;
|
|
|
|
|
|
|
|
num_pedestrians++;
|
|
|
|
pUsedPeds = pNewPed;
|
|
|
|
|
|
|
|
return pNewPed;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 10:12:13 +02:00
|
|
|
|
|
|
|
return NULL;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void PlaceRoadBlockCops(void)
|
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
int wbody;
|
|
|
|
int lbody;
|
|
|
|
int cs, sn;
|
2021-04-04 21:33:43 +02:00
|
|
|
u_int dir;
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* cp;
|
|
|
|
CAR_DATA* pCar;
|
2020-10-11 12:19:12 +02:00
|
|
|
int i;
|
|
|
|
int numCops;
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* pCopCars[16];
|
2020-12-08 17:45:14 +01:00
|
|
|
LONGVECTOR4 disp;
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (numCopPeds >= 8)
|
|
|
|
return;
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
numCops = 0;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
cp = car_data;
|
|
|
|
do {
|
|
|
|
if (cp->controlFlags & CONTROL_FLAG_COP_SLEEPING)
|
|
|
|
pCopCars[numCops++] = cp;
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
cp++;
|
|
|
|
} while (cp < &car_data[MAX_CARS]);
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (!numCops)
|
|
|
|
return;
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
i = 0;
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
do {
|
|
|
|
pCar = pCopCars[i];
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
sn = rsin(pCar->hd.direction);
|
|
|
|
cs = rcos(pCar->hd.direction);
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
disp[0] = pCar->hd.where.t[0] - player[0].pos[0];
|
|
|
|
disp[1] = player[0].pos[1] - pCar->hd.where.t[1];
|
|
|
|
disp[2] = pCar->hd.where.t[2] - player[0].pos[2];
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
lbody = car_cosmetics[pCar->ap.model].colBox.vz - 120;
|
|
|
|
wbody = car_cosmetics[pCar->ap.model].colBox.vx + 400;
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (FIXED(cs * 0x1000) * disp[0] - FIXED(sn * 0x1000) * disp[2] + 0x800 < 0)
|
|
|
|
wbody = -wbody;
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
dir = pCar->hd.direction + 0x800U & 0xfff;
|
|
|
|
cs = rcossin_tbl[dir * 2 + 1];
|
|
|
|
sn = rcossin_tbl[dir * 2];
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
disp[0] = pCar->hd.where.t[0] - (FIXED(wbody * cs) - FIXED(lbody * sn));
|
|
|
|
disp[1] = -pCar->hd.where.t[1];
|
|
|
|
disp[2] = pCar->hd.where.t[2] + FIXED(wbody * sn) + FIXED(lbody * cs);
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-31 01:57:58 +01:00
|
|
|
if (CreatePedAtLocation(&disp, 12) != 0)
|
2020-10-11 12:19:12 +02:00
|
|
|
numCopPeds++;
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
disp[0] = pCar->hd.where.t[0] - (FIXED(wbody * cs) - FIXED(-lbody * sn));
|
|
|
|
disp[1] = -pCar->hd.where.t[1];
|
|
|
|
disp[2] = pCar->hd.where.t[2] + FIXED(wbody * sn) + FIXED(-lbody * cs);
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-31 01:57:58 +01:00
|
|
|
if (CreatePedAtLocation(&disp, 13) != 0)
|
2020-10-11 12:19:12 +02:00
|
|
|
numCopPeds++;
|
2020-07-05 18:56:30 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
i++;
|
|
|
|
} while (i < numCops);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-12-08 17:45:14 +01:00
|
|
|
int CreatePedAtLocation(LONGVECTOR4* pPos, int pedType)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* pPed;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (num_pedestrians >= MAX_PLACED_PEDS)
|
2020-05-24 10:21:19 +02:00
|
|
|
return 0;
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed = CreatePedestrian();
|
2020-05-24 10:21:19 +02:00
|
|
|
|
|
|
|
if (pPed == NULL)
|
2020-04-03 00:44:09 +02:00
|
|
|
return 0;
|
2020-05-24 10:21:19 +02:00
|
|
|
|
|
|
|
pPed->position.vx = (*pPos)[0];
|
|
|
|
pPed->position.vy = (*pPos)[1];
|
|
|
|
pPed->position.vz = (*pPos)[2];
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->pedType = CIVILIAN;
|
2020-05-24 10:21:19 +02:00
|
|
|
|
|
|
|
pPed->dir.vz = 0;
|
|
|
|
pPed->dir.vx = 0;
|
|
|
|
pPed->dir.vy = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = (PED_ACTION_TYPE)pedType;
|
|
|
|
pPed->flags = 0;
|
2020-05-24 10:21:19 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->fpRestState = fpPedPersonalityFunctions[12];
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pedType == 8)
|
2020-05-24 10:21:19 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->flags = 0;
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->fpRestState = fpPedPersonalityFunctions[7];
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else if (pedType >= 8 && pedType <= 13)
|
2020-05-24 10:21:19 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->flags = 8;
|
2020-05-24 10:21:19 +02:00
|
|
|
pPed->pallet = 85;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-24 10:21:19 +02:00
|
|
|
|
|
|
|
pPed->fpAgitatedState = NULL;
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupPedMotionData(pPed);
|
2020-05-24 10:21:19 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->type == PED_ACTION_COPSTAND)
|
2020-05-24 10:21:19 +02:00
|
|
|
{
|
2020-09-27 11:28:21 +02:00
|
|
|
pPed->position.vy = -(*pPos)[1];
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->position.vy = -98 - MapHeight((VECTOR*)&pPed->position);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-09-27 11:28:21 +02:00
|
|
|
else if (pPed->type == PED_ACTION_COPCROUCH)
|
2020-05-24 10:21:19 +02:00
|
|
|
{
|
2020-09-27 11:28:21 +02:00
|
|
|
pPed->position.vy = -(*pPos)[1];
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->position.vy = -62 - MapHeight((VECTOR*)&pPed->position);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-24 10:21:19 +02:00
|
|
|
|
|
|
|
return 1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DrawAllPedestrians(void)
|
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* pPed;
|
2020-05-24 16:12:10 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed = pUsedPeds;
|
2020-05-24 16:12:10 +02:00
|
|
|
while (pPed != NULL)
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
if (PositionVisible((VECTOR*)&pPed->position) &&
|
2020-10-11 12:19:12 +02:00
|
|
|
FrustrumCheck((VECTOR*)&pPed->position, 60) != -1)
|
|
|
|
{
|
2020-11-19 18:01:55 +01:00
|
|
|
if (pPed->pedType == TANNER_MODEL)
|
2020-10-11 12:19:12 +02:00
|
|
|
{
|
|
|
|
if (!bKillTanner)
|
|
|
|
DrawTanner(pPed);
|
|
|
|
}
|
2020-11-19 18:01:55 +01:00
|
|
|
else if (pPed->pedType == OTHER_MODEL)
|
|
|
|
{
|
|
|
|
if (!bKillTanner)
|
|
|
|
DrawCharacter(pPed);
|
|
|
|
}
|
2020-10-11 15:38:07 +02:00
|
|
|
else if (pPed->pedType == OTHER_SPRITE)
|
2020-10-11 12:19:12 +02:00
|
|
|
{
|
|
|
|
DrawCharacter(pPed);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawCiv(pPed);
|
|
|
|
}
|
|
|
|
}
|
2020-05-24 16:12:10 +02:00
|
|
|
|
|
|
|
pPed = pPed->pNext;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-24 16:12:10 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
/*
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed = pUsedPeds;
|
2020-10-11 12:19:12 +02:00
|
|
|
while (pPed != NULL)
|
2020-05-24 16:12:10 +02:00
|
|
|
{
|
2020-09-04 21:09:51 +02:00
|
|
|
if (pPed->pedType < OTHER_SPRITE && PedVisible(pPed, 60))
|
2020-05-24 16:12:10 +02:00
|
|
|
{
|
2020-09-04 21:09:51 +02:00
|
|
|
if (!bKillTanner)
|
|
|
|
DrawTanner(pPed);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-24 16:12:10 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed = pPed->pNext;
|
2020-10-11 12:19:12 +02:00
|
|
|
}*/
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int TannerActionHappening(void)
|
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* pPed = player[0].pPed;
|
2020-05-15 11:06:27 +02:00
|
|
|
|
|
|
|
if (pPed && pPed->type == PED_ACTION_PRESSBUTTON)
|
2020-09-10 19:53:30 +02:00
|
|
|
return pPed->frame1 == 14;
|
2020-05-15 11:06:27 +02:00
|
|
|
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-05-15 11:06:27 +02:00
|
|
|
int bAvoidTanner = 0;
|
|
|
|
int bAvoidBomb = -1;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void ControlPedestrians(void)
|
|
|
|
{
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* pCar;
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* pPed;
|
|
|
|
PEDESTRIAN* pPedNext;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
|
|
|
pPed = pUsedPeds;
|
2020-05-15 11:06:27 +02:00
|
|
|
|
|
|
|
while (pPed)
|
|
|
|
{
|
|
|
|
pPedNext = pPed->pNext; // in case if ped gets removed
|
|
|
|
|
|
|
|
if (pPed->pedType == CIVILIAN)
|
|
|
|
{
|
|
|
|
CalculatePedestrianInterest(pPed);
|
|
|
|
|
|
|
|
if (pPed->fpAgitatedState == NULL)
|
|
|
|
(*pPed->fpRestState)(pPed);
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 11:06:27 +02:00
|
|
|
(*pPed->fpAgitatedState)(pPed);
|
|
|
|
|
|
|
|
if (pPed->type != PED_ACTION_GETINCAR)
|
|
|
|
{
|
|
|
|
pCar = CheckForCar(pPed);
|
|
|
|
|
|
|
|
if (pCar)
|
|
|
|
SetupCivJump(pPed, pCar);
|
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (bAvoidTanner == 0)
|
2020-05-15 11:06:27 +02:00
|
|
|
{
|
|
|
|
if (bAvoidBomb != -1)
|
2020-04-03 00:44:09 +02:00
|
|
|
{
|
2020-05-15 11:06:27 +02:00
|
|
|
SetupCivJump(pPed, NULL);
|
|
|
|
bAvoidBomb = -1;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 11:06:27 +02:00
|
|
|
{
|
|
|
|
SetupCivJump(pPed, NULL);
|
|
|
|
bAvoidTanner = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pPed = pPedNext;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 11:06:27 +02:00
|
|
|
|
|
|
|
pPed = pUsedPeds;
|
|
|
|
|
|
|
|
// remove peds with PingOut
|
|
|
|
while (pPed)
|
|
|
|
{
|
|
|
|
if (pPed->pedType == CIVILIAN && (PingOutPed(pPed) != 0 || (pPed->flags & 1U) != 0))
|
|
|
|
{
|
|
|
|
pHold = pPed->pNext;
|
|
|
|
DestroyPedestrian(pPed);
|
|
|
|
pPed = pHold;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 11:06:27 +02:00
|
|
|
{
|
|
|
|
pPed = pPed->pNext;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-12-09 09:33:57 +01:00
|
|
|
void AnimatePed(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-12-09 09:33:57 +01:00
|
|
|
int dir;
|
|
|
|
VECTOR vec;
|
2020-05-15 11:06:27 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
if (pauseflag)
|
|
|
|
return;
|
|
|
|
|
|
|
|
vec.vx = pPed->position.vx;
|
|
|
|
vec.vz = pPed->position.vz;
|
|
|
|
vec.vy = -pPed->position.vy;
|
|
|
|
|
|
|
|
if (pPed->type != PED_ACTION_SIT)
|
|
|
|
{
|
|
|
|
if (pPed->pedType == CIVILIAN && (pPed->flags & 0x8000U) != 0)
|
|
|
|
pPed->position.vy = -60 - MapHeight(&vec);
|
|
|
|
else
|
|
|
|
pPed->position.vy = -130 - MapHeight(&vec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPed->speed < 0)
|
|
|
|
{
|
|
|
|
dir = pPed->dir.vy;
|
|
|
|
pPed->position.vx -= FIXED(pPed->speed * rcossin_tbl[(dir & 0xfff) * 2]);
|
|
|
|
pPed->position.vz -= FIXED(pPed->speed * rcossin_tbl[(-dir & 0xfffU) * 2 + 1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dir = pPed->dir.vy - 0x800U & 0xfff;
|
|
|
|
pPed->position.vx += FIXED(pPed->speed * rcossin_tbl[dir * 2]);
|
|
|
|
pPed->position.vz += FIXED(pPed->speed * rcossin_tbl[dir * 2 + 1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPed->type != PED_ACTION_SIT &&
|
|
|
|
pPed->type != PED_ACTION_COPCROUCH &&
|
|
|
|
pPed->type != PED_ACTION_COPSTAND)
|
|
|
|
{
|
|
|
|
pPed->velocity.vy = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pPed->flags & 4) /*&& pPed->pedType == TANNER_MODEL*/)
|
|
|
|
{
|
|
|
|
if (pPed->frame1 == 0)
|
|
|
|
pPed->frame1 = 15;
|
|
|
|
|
|
|
|
pPed->frame1--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-09 11:44:49 +02:00
|
|
|
int g_cdNumFrames;
|
2020-12-09 09:33:57 +01:00
|
|
|
pPed->frame1++;
|
|
|
|
|
|
|
|
if (pPed->type - 8U < 3) // [A] TODO: figure out what type it is to have extended frames
|
2021-04-09 11:44:49 +02:00
|
|
|
g_cdNumFrames = 31;
|
2020-12-09 09:33:57 +01:00
|
|
|
else
|
2021-04-09 11:44:49 +02:00
|
|
|
g_cdNumFrames = 16;
|
2020-12-09 09:33:57 +01:00
|
|
|
|
2021-04-09 11:44:49 +02:00
|
|
|
if (pPed->frame1 >= g_cdNumFrames)
|
2020-12-09 09:33:57 +01:00
|
|
|
pPed->frame1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pPed->pedType == TANNER_MODEL || (ActiveCheats.cheat12 && pPed->pedType == OTHER_MODEL)) && pPed->type < PED_ACTION_BACK)
|
|
|
|
{
|
|
|
|
int surfId;
|
|
|
|
surfId = PedSurfaceType((VECTOR*)&pPed->position);
|
|
|
|
|
|
|
|
// play footstep sounds
|
|
|
|
if (surfId != 4 && surfId != 6 && surfId != 11 && surfId != 9)
|
|
|
|
{
|
|
|
|
if (pPed->frame1 == 3)
|
|
|
|
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 0, pPed->position.vx, -pPed->position.vy, pPed->position.vz, -5000, 0x1000);
|
|
|
|
|
|
|
|
if (pPed->frame1 == 11)
|
|
|
|
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 1, pPed->position.vx, -pPed->position.vy, pPed->position.vz, -5000, 0x1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPed->pedType != CIVILIAN)
|
|
|
|
{
|
|
|
|
int padId;
|
|
|
|
padId = ABS(pPed->padId);
|
|
|
|
|
|
|
|
player[padId].pos[0] = pPed->position.vx;
|
|
|
|
player[padId].pos[1] = -pPed->position.vy;
|
|
|
|
player[padId].pos[2] = pPed->position.vz;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
// [D] [T]
|
|
|
|
void SetupDoNowt(PEDESTRIAN* pPed)
|
|
|
|
{
|
|
|
|
pPed->speed = 0;
|
|
|
|
pPed->dir.vz = 0;
|
|
|
|
pPed->type = PED_ACTION_BACK;
|
|
|
|
|
|
|
|
SetupPedMotionData(pPed);
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
pPed->flags |= 0x10;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void SetupWalker(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_WALK;
|
2020-05-15 11:18:42 +02:00
|
|
|
pPed->speed = 14;
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupPedMotionData(pPed);
|
2020-05-15 11:18:42 +02:00
|
|
|
|
|
|
|
pPed->flags |= 0x10;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void SetupRunner(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_RUN;
|
2020-05-15 14:41:42 +02:00
|
|
|
pPed->frame1 = 0;
|
2020-05-15 11:18:42 +02:00
|
|
|
pPed->speed = 40;
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupPedMotionData(pPed);
|
2020-05-15 11:18:42 +02:00
|
|
|
|
|
|
|
pPed->flags |= 0x10;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void SetupBack(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_WALK;
|
2020-05-15 11:18:42 +02:00
|
|
|
pPed->frame1 = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->speed = -10;
|
|
|
|
SetupPedMotionData(pPed);
|
2020-05-15 11:18:42 +02:00
|
|
|
|
|
|
|
pPed->flags |= 0x10;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* pCivCarToGetIn = NULL;
|
2020-05-15 11:18:42 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void CivGetIn(PEDESTRIAN* pPed) // [A] UNUSED
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2021-04-04 21:33:43 +02:00
|
|
|
u_int padid;
|
2020-10-11 12:19:12 +02:00
|
|
|
DRIVER2_CURVE* curve;
|
|
|
|
DRIVER2_STRAIGHT* straight;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-05-15 11:18:42 +02:00
|
|
|
straight = NULL;
|
|
|
|
curve = NULL;
|
|
|
|
|
|
|
|
InitCivState(pCivCarToGetIn, NULL);
|
2020-10-11 12:19:12 +02:00
|
|
|
|
|
|
|
if (IS_STRAIGHT_SURFACE(pCivCarToGetIn->ai.c.currentRoad))
|
|
|
|
straight = GET_STRAIGHT(pCivCarToGetIn->ai.c.currentRoad);
|
2020-05-15 11:18:42 +02:00
|
|
|
else
|
2020-10-11 12:19:12 +02:00
|
|
|
curve = GET_CURVE(pCivCarToGetIn->ai.c.currentRoad);
|
2020-05-15 11:18:42 +02:00
|
|
|
|
|
|
|
pCivCarToGetIn->ai.c.currentLane = CheckChangeLanes(straight, curve, pCivCarToGetIn->ai.c.targetRoute[0].distAlongSegment, pCivCarToGetIn, 0);
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
DestroyPedestrian(pPed);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void CopStand(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-15 11:18:42 +02:00
|
|
|
VECTOR v;
|
|
|
|
v.vx = pPed->position.vx - player[0].pos[0];
|
|
|
|
v.vz = pPed->position.vz - player[0].pos[2];
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-05-15 11:18:42 +02:00
|
|
|
pPed->frame1 = 0;
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->dir.vy = 1024 - ratan2(v.vz, v.vx);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-05-15 11:36:25 +02:00
|
|
|
int iAllowWatch = 0;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void PedDoNothing(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-15 11:36:25 +02:00
|
|
|
pPed->speed = 0;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if ((pPed->flags & 0x10) == 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupDoNowt(pPed);
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->flags |= 0x10;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-20 19:41:56 +02:00
|
|
|
if (tannerPad & TANNER_PAD_GOFORWARD)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
// run forward
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->interest = 0;
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->fpAgitatedState = fpPedPersonalityFunctions[2];
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
SetupRunner(pPed);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-20 19:41:56 +02:00
|
|
|
else if (tannerPad & TANNER_PAD_GOBACK)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
// walk back
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->interest = 0;
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->fpAgitatedState = fpPedPersonalityFunctions[1];
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupBack(pPed);
|
|
|
|
}
|
2020-10-20 19:41:56 +02:00
|
|
|
else if (tannerPad & TANNER_PAD_TURNRIGHT)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->interest = 0;
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->doing_turn -= 2;
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
if (pPed->doing_turn < -tannerTurnMax)
|
|
|
|
pPed->doing_turn = -tannerTurnMax;
|
2020-06-22 19:50:29 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->dir.vy = pPed->dir.vy + 64 - (pPed->doing_turn + tannerTurnMax) * tannerTurnStep;
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
if (pPed->frame1 == 0)
|
|
|
|
pPed->frame1 = 15;
|
|
|
|
else
|
|
|
|
pPed->frame1--;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->head_rot = 0;
|
|
|
|
}
|
2020-10-20 19:41:56 +02:00
|
|
|
else if (tannerPad & TANNER_PAD_TURNLEFT)
|
2020-10-08 20:18:59 +02:00
|
|
|
{
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->interest = 0;
|
2020-10-08 20:18:59 +02:00
|
|
|
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->doing_turn += 2;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
if (pPed->doing_turn > tannerTurnMax)
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->doing_turn = tannerTurnMax;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->dir.vy = pPed->dir.vy - 64 + (tannerTurnMax - pPed->doing_turn) * tannerTurnStep;
|
|
|
|
|
2020-10-13 18:49:21 +02:00
|
|
|
if (pPed->frame1 > 14)
|
2020-05-15 11:36:25 +02:00
|
|
|
pPed->frame1 = 0;
|
2020-10-13 18:49:21 +02:00
|
|
|
else
|
|
|
|
pPed->frame1++;
|
2020-10-08 20:18:59 +02:00
|
|
|
|
|
|
|
pPed->head_rot = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-08 20:18:59 +02:00
|
|
|
else
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->frame1 = 0;
|
|
|
|
pPed->interest += 1;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->doing_turn < 0)
|
2020-10-08 20:18:59 +02:00
|
|
|
{
|
|
|
|
pPed->doing_turn += 2;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
if (pPed->doing_turn > 0)
|
|
|
|
pPed->doing_turn = 0;
|
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
if (pPed->doing_turn > 0)
|
|
|
|
{
|
|
|
|
pPed->doing_turn -= 2;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->doing_turn < 0)
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->doing_turn = 0;
|
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
if (pPed->doing_turn != 0)
|
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->doing_turn < 0)
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->dir.vy = pPed->dir.vy + 64 - (pPed->doing_turn + tannerTurnMax) * tannerTurnStep;
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->dir.vy = pPed->dir.vy - 64 + (tannerTurnMax - pPed->doing_turn) * tannerTurnStep;
|
|
|
|
}
|
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
|
|
|
|
if (pPed->interest > 119)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
|
|
|
pPed->frame1 = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_TIME;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupPedMotionData(pPed);
|
2020-05-15 11:36:25 +02:00
|
|
|
|
|
|
|
pPed->flags |= 0x10;
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->fpAgitatedState = fpPedPersonalityFunctions[5];
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->interest = -2;
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-05-15 11:36:25 +02:00
|
|
|
if (pPed->type == PED_ACTION_TIME)
|
2020-04-03 00:44:09 +02:00
|
|
|
iAllowWatch = 3;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
|
|
|
if (iAllowWatch != 0)
|
|
|
|
iAllowWatch--;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void PedUserRunner(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-06-22 19:50:29 +02:00
|
|
|
if ((pPed->flags & 0x10U) == 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupRunner(pPed);
|
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-20 19:41:56 +02:00
|
|
|
if (tannerPad & TANNER_PAD_GOFORWARD)
|
2020-10-08 20:18:59 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (bStopTanner == 0)
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->speed = 40 - (tannerDeathTimer >> 1);
|
|
|
|
else
|
|
|
|
pPed->speed = 0;
|
|
|
|
}
|
|
|
|
else
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
|
|
|
pPed->dir.vz = 0;
|
|
|
|
pPed->speed = 0;
|
|
|
|
pPed->fpAgitatedState = NULL;
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-10-20 19:41:56 +02:00
|
|
|
if (tannerPad & TANNER_PAD_TURNRIGHT)
|
2020-06-22 19:50:29 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->dir.vz > -80)
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->dir.vz -= 20;
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->doing_turn -= 2;
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-06-22 19:50:29 +02:00
|
|
|
if (pPed->doing_turn < -tannerTurnMax)
|
|
|
|
pPed->doing_turn = -tannerTurnMax;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->head_rot = 0;
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->dir.vy = pPed->dir.vy + 64 - (pPed->doing_turn + tannerTurnMax) * tannerTurnStep;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-20 19:41:56 +02:00
|
|
|
else if (tannerPad & TANNER_PAD_TURNLEFT)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-10-08 20:18:59 +02:00
|
|
|
if (pPed->dir.vz < 80)
|
|
|
|
pPed->dir.vz += 20;
|
|
|
|
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->doing_turn += 2;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
if (pPed->doing_turn > tannerTurnMax)
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->doing_turn = tannerTurnMax;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->head_rot = 0;
|
|
|
|
pPed->dir.vy = pPed->dir.vy - 64 + (tannerTurnMax - pPed->doing_turn) * tannerTurnStep;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-08 20:18:59 +02:00
|
|
|
else
|
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->dir.vz < 0)
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->dir.vz += 40;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-08 20:18:59 +02:00
|
|
|
if (pPed->dir.vz > 0)
|
|
|
|
pPed->dir.vz -= 40;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->doing_turn < 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->doing_turn += 2;
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->doing_turn > 0)
|
2020-10-08 20:18:59 +02:00
|
|
|
pPed->doing_turn = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-08 20:18:59 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->doing_turn > 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-06-22 19:50:29 +02:00
|
|
|
pPed->doing_turn -= 2;
|
|
|
|
|
|
|
|
if (pPed->doing_turn < 0)
|
|
|
|
pPed->doing_turn = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-08 20:18:59 +02:00
|
|
|
|
|
|
|
pPed->dir.vy = pPed->dir.vy - 64 + (tannerTurnMax - pPed->doing_turn) * tannerTurnStep;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
AnimatePed(pPed);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void PedUserWalker(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if ((pPed->flags & 0x10) == 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupWalker(pPed);
|
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-20 19:41:56 +02:00
|
|
|
if (tannerPad & TANNER_PAD_GOBACK)
|
2020-10-11 12:19:12 +02:00
|
|
|
{
|
|
|
|
pPed->speed = -10;
|
|
|
|
}
|
|
|
|
else
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_STOPPING;
|
2020-05-15 11:36:25 +02:00
|
|
|
pPed->frame1 = 0;
|
|
|
|
pPed->speed = 0;
|
|
|
|
pPed->fpAgitatedState = NULL;
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-20 19:41:56 +02:00
|
|
|
if (tannerPad & TANNER_PAD_TURNRIGHT)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->head_rot = 0;
|
2020-05-15 11:36:25 +02:00
|
|
|
pPed->dir.vy += 20;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-20 19:41:56 +02:00
|
|
|
if (tannerPad & TANNER_PAD_TURNLEFT)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->head_rot = 0;
|
2020-05-15 11:36:25 +02:00
|
|
|
pPed->dir.vy -= 20;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
AnimatePed(pPed);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-05-15 11:36:25 +02:00
|
|
|
int iFreezeTimer = 0;
|
|
|
|
int bFreezeAnimation = 0;
|
|
|
|
int allreadydone = 0;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void PedCarryOutAnimation(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-15 11:36:25 +02:00
|
|
|
pPed->speed = 0;
|
2020-10-20 19:41:56 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (tannerPad != 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
|
|
|
pPed->frame1 = 0;
|
|
|
|
pPed->fpAgitatedState = NULL;
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
bFreezeAnimation = 0;
|
2020-06-22 20:10:11 +02:00
|
|
|
pPed->flags &= ~4;
|
2020-04-03 00:44:09 +02:00
|
|
|
allreadydone = 0;
|
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (bFreezeAnimation == 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
AnimatePed(pPed);
|
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
|
|
|
if (iFreezeTimer == 0)
|
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
bFreezeAnimation = 0;
|
2020-06-22 20:10:11 +02:00
|
|
|
pPed->flags |= 4;
|
2020-04-03 00:44:09 +02:00
|
|
|
iFreezeTimer = 0;
|
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
|
|
|
iFreezeTimer--;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-06-22 20:10:11 +02:00
|
|
|
if ((pPed->flags & 4) == 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-06-22 19:50:29 +02:00
|
|
|
if (pPed->frame1 > 14 && bFreezeAnimation == 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->type == PED_ACTION_TIME)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
bFreezeAnimation = 1;
|
2020-06-22 19:50:29 +02:00
|
|
|
iFreezeTimer = 12;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
|
|
|
pPed->frame1 = 0;
|
|
|
|
pPed->fpAgitatedState = NULL;
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-28 23:31:45 +02:00
|
|
|
else if (pPed->frame1 == 0)
|
2020-05-15 11:36:25 +02:00
|
|
|
{
|
2020-06-28 23:31:45 +02:00
|
|
|
pPed->frame1 = 0;
|
|
|
|
pPed->fpAgitatedState = NULL;
|
|
|
|
pPed->flags &= ~0x10;
|
2020-05-15 11:36:25 +02:00
|
|
|
|
2020-06-28 23:31:45 +02:00
|
|
|
bFreezeAnimation = 0;
|
|
|
|
pPed->flags &= ~4;
|
|
|
|
allreadydone = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* carToGetIn;
|
2020-05-15 11:53:03 +02:00
|
|
|
int bReverseYRotation = 0;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void PedGetOutCar(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-06-06 12:29:36 +02:00
|
|
|
int playerId;
|
|
|
|
|
|
|
|
playerId = pPed->padId;
|
|
|
|
|
2020-05-15 11:53:03 +02:00
|
|
|
pPed->speed = 0;
|
|
|
|
pPed->frame1++;
|
|
|
|
|
2020-06-06 12:29:36 +02:00
|
|
|
player[playerId].pos[0] = pPed->position.vx;
|
|
|
|
player[playerId].pos[1] = -pPed->position.vy;
|
|
|
|
player[playerId].pos[2] = pPed->position.vz;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
|
|
|
if (pPed->frame1 > 14)
|
|
|
|
{
|
2020-06-06 12:29:36 +02:00
|
|
|
ChangeCarPlayerToPed(playerId);
|
2020-05-15 11:53:03 +02:00
|
|
|
|
|
|
|
pPed->speed = 0;
|
|
|
|
pPed->fpAgitatedState = NULL;
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-05-15 11:53:03 +02:00
|
|
|
pPed->dir.vy = carToGetIn->hd.direction - 2048;
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
bReverseYRotation = 0;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-15 11:53:03 +02:00
|
|
|
int lastCarCameraView = 0;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
void SetupGetOutCar(PEDESTRIAN* pPed, CAR_DATA* pCar, int side)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
bool entrySide;
|
|
|
|
int sn, cs;
|
2021-04-04 21:33:43 +02:00
|
|
|
u_int carDir;
|
2020-10-11 12:19:12 +02:00
|
|
|
int xOfs;
|
2020-06-06 12:29:36 +02:00
|
|
|
int playerId;
|
|
|
|
|
|
|
|
playerId = pPed->padId;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-06-06 12:29:36 +02:00
|
|
|
lastCarCameraView = player[playerId].cameraView;
|
2020-05-15 11:53:03 +02:00
|
|
|
pPed->speed = 0;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
sn = rsin(pCar->hd.direction);
|
|
|
|
cs = rcos(pCar->hd.direction);
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
entrySide = cs * (pCar->hd.where.t[0] - pPed->position.vx) - FIXED(sn * 0x1000) * (pCar->hd.where.t[2] - pPed->position.vz) + 0x800 > -1;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (entrySide)
|
|
|
|
pPed->dir.vy = pCar->hd.direction - 1024;
|
2020-05-15 11:53:03 +02:00
|
|
|
else
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->dir.vy = pCar->hd.direction + 1024;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
bReverseYRotation = !entrySide;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
|
|
|
if (side == 1)
|
2020-10-11 12:19:12 +02:00
|
|
|
xOfs = -400;
|
|
|
|
else
|
|
|
|
xOfs = 400;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
carDir = pCar->hd.direction + 0x800U & 0xfff;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
|
|
|
if (NoPlayerControl == 0)
|
|
|
|
{
|
2020-06-06 12:29:36 +02:00
|
|
|
player[playerId].cameraView = 5;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
player[playerId].cameraPos.vx = pCar->hd.where.t[0] - (FIXED(xOfs * rcossin_tbl[carDir * 2 + 1]) - FIXED(rcossin_tbl[carDir * 2] * 800));
|
2020-06-06 12:29:36 +02:00
|
|
|
player[playerId].cameraPos.vy = -200 - pCar->hd.where.t[1];
|
2020-10-11 12:19:12 +02:00
|
|
|
player[playerId].cameraPos.vz = pCar->hd.where.t[2] + (FIXED(xOfs * rcossin_tbl[carDir * 2]) + FIXED(rcossin_tbl[carDir * 2 + 1] * 800));
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 11:53:03 +02:00
|
|
|
|
|
|
|
pPed->frame1 = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
carToGetIn = pCar;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void SetupGetInCar(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
int sn, cs;
|
|
|
|
int carDir;
|
|
|
|
int xOfs;
|
|
|
|
int playerId;
|
|
|
|
int entrySide;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-12-08 17:45:14 +01:00
|
|
|
LONGVECTOR4 pos;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-06-22 20:10:11 +02:00
|
|
|
pPed->flags &= ~4;
|
2020-05-15 11:53:03 +02:00
|
|
|
pPed->speed = 0;
|
2020-05-18 07:39:39 +02:00
|
|
|
pPed->frame1 = 0;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
playerId = pPed->padId;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
sn = rsin(carToGetIn->hd.direction);
|
|
|
|
cs = rcos(carToGetIn->hd.direction);
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-12-07 07:35:49 +01:00
|
|
|
entrySide = cs * (carToGetIn->hd.where.t[0] - pPed->position.vx) - FIXED(sn * ONE) * (carToGetIn->hd.where.t[2] - pPed->position.vz) + 2048 < 0;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (entrySide)
|
2020-12-07 07:35:49 +01:00
|
|
|
pPed->dir.vy = carToGetIn->hd.direction + 1024;
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-12-07 07:35:49 +01:00
|
|
|
pPed->dir.vy = carToGetIn->hd.direction - 1024;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->dir.vy > carToGetIn->hd.direction)
|
|
|
|
xOfs = -400;
|
|
|
|
else
|
|
|
|
xOfs = 400;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
carDir = carToGetIn->hd.direction + 0x800U & 0xfff;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (NoPlayerControl == 0 && gInGameCutsceneActive == 0)
|
2020-05-15 11:53:03 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
player[playerId].cameraView = 5;
|
|
|
|
player[playerId].cameraPos.vx = carToGetIn->hd.where.t[0] - (FIXED(xOfs * rcossin_tbl[carDir * 2 + 1]) - FIXED(rcossin_tbl[carDir * 2] * 800));
|
|
|
|
player[playerId].cameraPos.vy = -200 - carToGetIn->hd.where.t[1];
|
|
|
|
player[playerId].cameraPos.vz = carToGetIn->hd.where.t[2] + (FIXED(xOfs * rcossin_tbl[carDir * 2]) + FIXED(rcossin_tbl[carDir * 2 + 1] * 800));
|
2020-05-15 11:53:03 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if ((carToGetIn->controlFlags & CONTROL_FLAG_WAS_PARKED) == 0)
|
2020-05-15 11:53:03 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (carToGetIn->controlType == CONTROL_TYPE_CIV_AI && carToGetIn->ai.c.thrustState == 3 && carToGetIn->ai.c.ctrlState == 5)
|
2020-05-15 11:53:03 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
carToGetIn->controlFlags |= CONTROL_FLAG_WAS_PARKED;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 11:53:03 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
pos[0] = player[playerId].pos[0];
|
|
|
|
pos[1] = -player[playerId].pos[1];
|
|
|
|
pos[2] = player[playerId].pos[2];
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-05-15 14:41:42 +02:00
|
|
|
// HEY!
|
2020-05-15 11:53:03 +02:00
|
|
|
CreatePedAtLocation(&pos, 8);
|
2020-11-01 21:27:24 +01:00
|
|
|
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 5, pos[0], pos[1], pos[2], 0, 0x1000);
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
carToGetIn->controlFlags |= CONTROL_FLAG_WAS_PARKED;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void PedGetInCar(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
int playerID;
|
|
|
|
|
2020-05-15 11:53:03 +02:00
|
|
|
pPed->speed = 0;
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->frame1 < 0xf)
|
2020-05-15 11:53:03 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
AnimatePed(pPed);
|
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 11:53:03 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
playerID = ABS(pPed->padId);
|
|
|
|
|
2020-05-15 11:53:03 +02:00
|
|
|
pPed->speed = 0;
|
|
|
|
pPed->fpAgitatedState = NULL;
|
|
|
|
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
ChangePedPlayerToCar(playerID, carToGetIn);
|
2020-04-03 00:44:09 +02:00
|
|
|
DestroyPedestrian(pPed);
|
2020-05-15 11:53:03 +02:00
|
|
|
|
|
|
|
pPlayerPed = NULL;
|
|
|
|
numTannerPeds--;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void SetupPressButton(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_PRESSBUTTON;
|
|
|
|
SetupPedMotionData(pPed);
|
2020-05-15 11:53:03 +02:00
|
|
|
|
2020-11-03 18:35:58 +01:00
|
|
|
pPed->dir.vz = 0;
|
2020-05-15 11:53:03 +02:00
|
|
|
pPed->speed = 0;
|
|
|
|
pPed->frame1 = 0;
|
|
|
|
pPed->fpAgitatedState = PedPressButton;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void PedPressButton(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->frame1 < 15)
|
2020-05-15 12:00:42 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
AnimatePed(pPed);
|
|
|
|
}
|
2020-05-15 12:00:42 +02:00
|
|
|
else
|
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_BACK;
|
2020-05-15 12:00:42 +02:00
|
|
|
pPed->fpAgitatedState = NULL;
|
|
|
|
pPed->frame1 = 0;
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupPedMotionData(pPed);
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void SetupTannerSitDown(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_SIT;
|
|
|
|
SetupPedMotionData(pPed);
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-11-03 18:35:58 +01:00
|
|
|
pPed->dir.vz = 0;
|
2020-05-16 19:10:15 +02:00
|
|
|
pPed->speed = 0;
|
2020-05-15 12:00:42 +02:00
|
|
|
pPed->frame1 = 0;
|
|
|
|
pPed->fpAgitatedState = TannerSitDown;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void TannerCameraHandler(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
int value;
|
|
|
|
int padSteer;
|
|
|
|
int padid;
|
2020-05-15 12:00:42 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
padid = pPed->padId;
|
|
|
|
|
2020-05-15 12:00:42 +02:00
|
|
|
if (Pads[padid].type == 4)
|
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
padSteer = Pads[padid].mapanalog[0];
|
2020-05-15 12:00:42 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (padSteer < -32 || padSteer > 32)
|
2020-05-15 12:00:42 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (padSteer < 0)
|
|
|
|
value = -padSteer;
|
|
|
|
else
|
|
|
|
value = padSteer;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (padSteer < 0)
|
2020-11-14 22:26:36 +01:00
|
|
|
tannerLookAngle.vy = (value - 32) * -11;
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-11-14 22:26:36 +01:00
|
|
|
tannerLookAngle.vy = (value - 32) * 11;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 12:00:42 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
tannerLookAngle.vy = 0;
|
|
|
|
}
|
2020-05-15 12:00:42 +02:00
|
|
|
|
2020-11-14 22:26:36 +01:00
|
|
|
tannerLookAngle.vx = -Pads[padid].mapanalog[1] * 2;
|
2020-05-15 12:00:42 +02:00
|
|
|
|
2020-11-14 22:26:36 +01:00
|
|
|
if (tannerLookAngle.vx < -60)
|
|
|
|
tannerLookAngle.vx -= 128;
|
|
|
|
else if (tannerLookAngle.vx < 60)
|
2020-05-15 12:00:42 +02:00
|
|
|
tannerLookAngle.vx = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 12:00:42 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
tannerLookAngle.vx = 0;
|
|
|
|
tannerLookAngle.vy = 0;
|
|
|
|
tannerLookAngle.vz = 0;
|
|
|
|
}
|
2020-05-15 12:00:42 +02:00
|
|
|
|
2020-11-14 22:26:36 +01:00
|
|
|
// [A] old non-functioning code bloat removed
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void TannerSitDown(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-06-22 19:50:29 +02:00
|
|
|
if (oldCamView != 2 && player[pPed->padId].cameraView == 2)
|
2020-05-15 12:00:42 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
camAngle.vx = camera_angle.vx;
|
|
|
|
camAngle.vy = camera_angle.vy;
|
|
|
|
camAngle.vz = camera_angle.vz;
|
|
|
|
}
|
2020-05-15 12:00:42 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// if sit down/standup animation playing
|
|
|
|
if (pPed->flags & 4)
|
2020-10-11 15:38:07 +02:00
|
|
|
{
|
2020-05-15 12:00:42 +02:00
|
|
|
if (pPed->frame1 == 0)
|
|
|
|
{
|
|
|
|
pPed->frame1 = 0;
|
|
|
|
pPed->fpAgitatedState = NULL;
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-05-15 12:00:42 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
tannerLookAngle.vx = 0;
|
|
|
|
tannerLookAngle.vy = 0;
|
|
|
|
tannerLookAngle.vz = 0;
|
2020-06-22 20:00:23 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
bFreezeAnimation = 0;
|
2020-06-22 20:10:11 +02:00
|
|
|
pPed->flags &= ~4;
|
2020-04-03 00:44:09 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-05-15 12:00:42 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->position.vy -= 3;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 12:00:42 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->frame1 == 15)
|
|
|
|
{
|
|
|
|
oldCamView = player[pPed->padId].cameraView;
|
|
|
|
bFreezeAnimation = 1;
|
|
|
|
|
2020-10-20 19:41:56 +02:00
|
|
|
if (tannerPad & TANNER_PAD_ACTION)
|
2020-10-11 12:19:12 +02:00
|
|
|
{
|
|
|
|
tracking_car = 1;
|
|
|
|
pPed->flags |= 4; // new reverse animation flag
|
|
|
|
bFreezeAnimation = 0;
|
2020-05-15 12:00:42 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
oldCamView = -1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pPed->position.vy += 3;
|
|
|
|
}
|
2020-05-16 19:10:15 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
AnimatePed(pPed);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
// [D] [T]
|
|
|
|
void CivPedDoNothing(PEDESTRIAN* pPed)
|
|
|
|
{
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
2020-12-09 09:33:57 +01:00
|
|
|
void SetupCivPedRouteData(VECTOR* pPos)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-12-09 09:33:57 +01:00
|
|
|
VECTOR baseLoc;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
baseLoc.vx = pPos->vx;
|
|
|
|
baseLoc.vy = pPos->vy;
|
|
|
|
baseLoc.vz = pPos->vz;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
pedestrian_roads.pos = GetSurfaceIndex(&baseLoc);
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
baseLoc.vz = pPos->vz - 128;
|
|
|
|
pedestrian_roads.north = GetSurfaceIndex(&baseLoc);
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
baseLoc.vz = pPos->vz + 128;
|
|
|
|
pedestrian_roads.south = GetSurfaceIndex(&baseLoc);
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
baseLoc.vz = pPos->vz;
|
|
|
|
baseLoc.vx = pPos->vx - 128;
|
|
|
|
pedestrian_roads.east = GetSurfaceIndex(&baseLoc);
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
baseLoc.vx = pPos->vx + 128;
|
|
|
|
pedestrian_roads.west = GetSurfaceIndex(&baseLoc);
|
|
|
|
}
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
// [D] [T]
|
|
|
|
void PingInPedestrians(void)
|
|
|
|
{
|
|
|
|
int bFound;
|
|
|
|
PEDESTRIAN* pPed;
|
|
|
|
int rnd;
|
|
|
|
int pingInDist;
|
|
|
|
int i;
|
|
|
|
int dx, dz;
|
|
|
|
VECTOR randomLoc;
|
|
|
|
VECTOR baseLoc;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
if (num_pedestrians >= MAX_PLACED_PEDS || pFreePeds == NULL || pFreePeds->pNext == NULL)
|
|
|
|
return;
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
baseLoc.vx = player[0].pos[0];
|
|
|
|
baseLoc.vy = player[0].pos[1];
|
|
|
|
baseLoc.vz = player[0].pos[2];
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
if (gWeather == 0 && FindSeated() != NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < 50; i++)
|
2020-05-15 12:33:29 +02:00
|
|
|
{
|
2020-12-09 09:33:57 +01:00
|
|
|
pinginPedAngle += 81;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
pingInDist = Random2(0) % 128 + 1536;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
randomLoc.vy = baseLoc.vy;
|
|
|
|
randomLoc.vx = baseLoc.vx + pingInDist * FIXEDH(rcossin_tbl[(pinginPedAngle & 0xfffU) * 2] * 8);
|
|
|
|
randomLoc.vz = baseLoc.vz + pingInDist * FIXEDH(rcossin_tbl[(pinginPedAngle & 0xfffU) * 2 + 1] * 8);
|
|
|
|
|
|
|
|
randomLoc.vy = -MapHeight(&randomLoc);
|
2020-06-21 10:49:50 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (baseLoc.vy - 512 <= -randomLoc.vy &&
|
|
|
|
baseLoc.vy + 512 >= -randomLoc.vy &&
|
2020-10-11 12:19:12 +02:00
|
|
|
IsPavement(randomLoc.vx, randomLoc.vy, randomLoc.vz, NULL))
|
2020-06-21 10:49:50 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pUsedPeds != NULL)
|
|
|
|
{
|
|
|
|
pPed = pUsedPeds;
|
|
|
|
|
|
|
|
dx = pPed->position.vx - randomLoc.vx;
|
|
|
|
dz = pPed->position.vz - randomLoc.vz;
|
|
|
|
|
|
|
|
bFound = 0;
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
while (dx * dx + dz * dz > 15999999)
|
2020-04-03 00:44:09 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed = pPed->pNext;
|
|
|
|
|
|
|
|
if (pPed == NULL)
|
2020-06-21 10:49:50 +02:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
bFound = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
dx = pPed->position.vx - randomLoc.vx;
|
|
|
|
dz = pPed->position.vz - randomLoc.vz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bFound = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bFound)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pFreePeds->pNext == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pPed = CreatePedestrian();
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->flags = 0;
|
|
|
|
pPed->position.vx = randomLoc.vx;
|
|
|
|
pPed->position.vy = randomLoc.vy;
|
|
|
|
pPed->pedType = CIVILIAN;
|
|
|
|
pPed->dir.vz = 0;
|
|
|
|
pPed->dir.vx = 0;
|
|
|
|
pPed->dir.vy = 0;
|
|
|
|
pPed->position.vz = randomLoc.vz;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
baseLoc.vx = randomLoc.vx;
|
|
|
|
baseLoc.vy = pPed->position.vy;
|
|
|
|
baseLoc.vz = pPed->position.vz;
|
2020-06-21 10:49:50 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
baseLoc.vy = -MapHeight(&baseLoc);
|
2020-06-21 10:49:50 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
SetupCivPedRouteData(&baseLoc);
|
|
|
|
PedestrianActionInit_WalkToTarget(pPed);
|
2020-06-21 10:49:50 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->type = PED_ACTION_CIVRUN;
|
2020-06-21 10:49:50 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pedestrian_roads.north != -28 &&
|
|
|
|
(pPed->type = PED_ACTION_CIVRUN, pedestrian_roads.south != -28) &&
|
|
|
|
(pPed->type = PED_ACTION_CIVRUN, pedestrian_roads.east != -28) &&
|
|
|
|
(pPed->type = PED_ACTION_CIVWALK, pedestrian_roads.west == -28))
|
|
|
|
{
|
|
|
|
pPed->type = PED_ACTION_CIVRUN;
|
|
|
|
}
|
2020-06-21 10:49:50 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// it might not be correct
|
|
|
|
pPed->pallet = (Random2(-28) % 5) + (Random2(-28) % 5) * 16;
|
2020-06-21 10:49:50 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
SetupPedMotionData(pPed);
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
pPed->fpAgitatedState = NULL;
|
|
|
|
pPed->dir.vy = 0;
|
|
|
|
pPed->fpRestState = fpPedPersonalityFunctions[7];
|
2020-10-17 17:46:39 +02:00
|
|
|
pPed->speed = 0;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
rnd = Random2(0);
|
|
|
|
|
|
|
|
if ((rnd / 6) * 6 != rnd - 3)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pPed->flags |= 0x4000;
|
|
|
|
return;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
// [D] [T]
|
|
|
|
void TannerCollision(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* pcdTanner;
|
2020-10-11 12:19:12 +02:00
|
|
|
|
2020-05-24 10:22:31 +02:00
|
|
|
if (pPed->type == PED_ACTION_SIT)
|
|
|
|
return;
|
|
|
|
|
2020-10-20 12:17:12 +02:00
|
|
|
pcdTanner = &car_data[TANNER_COLLIDER_CARID];
|
2020-05-24 10:22:31 +02:00
|
|
|
|
2020-10-31 01:11:58 +01:00
|
|
|
ClearMem((char*)pcdTanner, sizeof(CAR_DATA));
|
2020-05-24 10:22:31 +02:00
|
|
|
|
2020-11-01 13:00:58 +01:00
|
|
|
pcdTanner->id = TANNER_COLLIDER_CARID;
|
2020-05-24 10:22:31 +02:00
|
|
|
pcdTanner->controlType = 6;
|
|
|
|
|
|
|
|
pcdTanner->hd.direction = pPed->dir.vy - 0x800U & 0xfff;
|
|
|
|
|
|
|
|
pcdTanner->hd.oBox.location.vx = pPed->position.vx;
|
|
|
|
pcdTanner->hd.where.t[0] = pPed->position.vx;
|
|
|
|
|
|
|
|
pcdTanner->hd.oBox.location.vy = -pPed->position.vy;
|
|
|
|
pcdTanner->hd.where.t[1] = -pPed->position.vy;
|
|
|
|
|
|
|
|
pcdTanner->hd.oBox.location.vz = pPed->position.vz;
|
|
|
|
pcdTanner->hd.where.t[2] = pPed->position.vz;
|
|
|
|
|
|
|
|
pcdTanner->st.n.linearVelocity[0] = 0;
|
|
|
|
pcdTanner->st.n.linearVelocity[1] = 0;
|
|
|
|
pcdTanner->st.n.linearVelocity[2] = 0;
|
|
|
|
|
|
|
|
CheckScenaryCollisions(pcdTanner);
|
2020-10-11 12:19:12 +02:00
|
|
|
TannerCarCollisionCheck((VECTOR*)&pPed->position, pPed->dir.vy, 0);
|
2020-05-24 10:22:31 +02:00
|
|
|
|
|
|
|
pPed->position.vx = pcdTanner->hd.where.t[0];
|
|
|
|
pPed->position.vz = pcdTanner->hd.where.t[2];
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
int FindPointOfCollision(CAR_DATA* pCar, PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int dx, dz;
|
|
|
|
int minZ;
|
|
|
|
int maxZ;
|
|
|
|
int minX;
|
|
|
|
int maxX;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-05-24 10:36:48 +02:00
|
|
|
CDATA2D cd[2];
|
2020-05-17 10:21:57 +02:00
|
|
|
static CRET2D collisionResult;
|
2020-10-11 12:19:12 +02:00
|
|
|
CAR_COSMETICS* car_cos;
|
|
|
|
|
|
|
|
car_cos = &car_cosmetics[pCar->ap.model];
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-05-17 20:03:34 +02:00
|
|
|
cd[0].length[0] = 120;
|
|
|
|
cd[0].length[1] = 12;
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-09-18 23:06:17 +02:00
|
|
|
cd[0].x.vx = pPed->position.vx;
|
|
|
|
cd[0].x.vz = pPed->position.vz;
|
|
|
|
cd[0].theta = pPed->dir.vy - 0x800U & 0xfff;
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
cd[1].length[0] = car_cos->colBox.vz;
|
|
|
|
cd[1].length[1] = car_cos->colBox.vx;
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-05-17 20:03:34 +02:00
|
|
|
cd[1].x.vx = pCar->hd.where.t[0];
|
|
|
|
cd[1].x.vz = pCar->hd.where.t[2];
|
|
|
|
cd[1].theta = pCar->hd.direction;
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-12-08 19:41:43 +01:00
|
|
|
if (!bcollided2d(cd))
|
2020-10-11 15:38:07 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
bFindCollisionPoint(cd, &collisionResult);
|
2020-05-17 10:21:57 +02:00
|
|
|
|
|
|
|
#if defined(COLLISION_DEBUG) && !defined(PSX)
|
2020-10-11 15:38:07 +02:00
|
|
|
extern int gShowCollisionDebug;
|
|
|
|
if (gShowCollisionDebug)
|
|
|
|
{
|
|
|
|
extern void Debug_AddLine(VECTOR & pointA, VECTOR & pointB, CVECTOR & color);
|
|
|
|
extern void Debug_AddLineOfs(VECTOR & pointA, VECTOR & pointB, VECTOR & ofs, CVECTOR & color);
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
CVECTOR bbcv = { 0, 0, 250 };
|
|
|
|
CVECTOR rrcv = { 250, 0, 0 };
|
|
|
|
CVECTOR yycv = { 250, 250, 0 };
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
VECTOR _zero = { 0, 100, 0 };
|
|
|
|
VECTOR up = { 0, 200, 0 };
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
Debug_AddLineOfs(_zero, up, cd[0].x, rrcv);
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
Debug_AddLineOfs(_zero, up, cd[1].x, yycv);
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
Debug_AddLineOfs(_zero, up, collisionResult.hit, bbcv);
|
|
|
|
}
|
2020-05-17 10:21:57 +02:00
|
|
|
#endif
|
|
|
|
|
2020-05-17 20:03:34 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
dx = FIXED((collisionResult.hit.vx - cd[1].x.vx) * rcossin_tbl[(cd[1].theta & 0xfffU) * 2 + 1]) -
|
|
|
|
FIXED((collisionResult.hit.vz - cd[1].x.vz) * rcossin_tbl[(cd[1].theta & 0xfffU) * 2]);
|
2020-05-17 20:03:34 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
dz = FIXED((collisionResult.hit.vx - cd[1].x.vx) * rcossin_tbl[(cd[1].theta & 0xfffU) * 2]) +
|
|
|
|
FIXED((collisionResult.hit.vz - cd[1].x.vz) * rcossin_tbl[(cd[1].theta & 0xfffU) * 2 + 1]);
|
2020-05-17 20:03:34 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
minX = car_cos->colBox.vx + 96;
|
|
|
|
maxX = car_cos->colBox.vx - 96;
|
2020-05-17 20:03:34 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
minZ = car_cos->colBox.vz - 480;
|
|
|
|
maxZ = car_cos->colBox.vz - 200;
|
2020-05-17 10:21:57 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (dz > minZ && dz < maxZ &&
|
|
|
|
(dx > maxX && dx < minX || dx < -maxX && dx > -minX))
|
|
|
|
{
|
|
|
|
return 1;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-17 20:03:34 +02:00
|
|
|
|
2020-05-17 10:21:57 +02:00
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
int TannerCarCollisionCheck(VECTOR* pPos, int dir, int bQuick)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* cp1;
|
2020-12-08 17:45:14 +01:00
|
|
|
LONGVECTOR4 pointVel;
|
|
|
|
LONGVECTOR4 reaction;
|
|
|
|
LONGVECTOR4 lever;
|
2020-10-11 15:38:07 +02:00
|
|
|
int strikeVel;
|
2020-09-29 16:00:01 +02:00
|
|
|
SVECTOR boxDisp;
|
|
|
|
CAR_COSMETICS* car_cos;
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* pcdTanner;
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-09-29 16:00:01 +02:00
|
|
|
CRET2D collisionResult; // offset 0x30
|
2020-05-24 10:36:48 +02:00
|
|
|
CDATA2D cd[2];
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-20 12:17:12 +02:00
|
|
|
pcdTanner = &car_data[TANNER_COLLIDER_CARID];
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-20 12:17:12 +02:00
|
|
|
cd[0].length[0] = 60;
|
|
|
|
cd[0].length[1] = 60;
|
2020-05-24 10:36:48 +02:00
|
|
|
cd[0].x.vx = pPos->vx;
|
|
|
|
cd[0].x.vz = pPos->vz;
|
|
|
|
cd[0].theta = dir;
|
|
|
|
|
2020-10-20 12:17:12 +02:00
|
|
|
cp1 = &car_data[MAX_CARS - 1];
|
2020-09-29 16:00:01 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
do {
|
2020-09-29 16:00:01 +02:00
|
|
|
car_cos = &car_cosmetics[cp1->ap.model];
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-09-29 16:00:01 +02:00
|
|
|
cd[1].length[0] = car_cos->colBox.vz;
|
|
|
|
cd[1].length[1] = car_cos->colBox.vx;
|
2020-05-24 10:36:48 +02:00
|
|
|
cd[1].theta = cp1->hd.direction;
|
|
|
|
|
2020-09-29 16:00:01 +02:00
|
|
|
// [A] fix bug with offset box collision
|
|
|
|
gte_SetRotMatrix(&cp1->hd.where);
|
|
|
|
gte_SetTransMatrix(&cp1->hd.where);
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-09-29 16:00:01 +02:00
|
|
|
boxDisp.vx = -car_cos->cog.vx;
|
|
|
|
boxDisp.vy = -car_cos->cog.vy;
|
|
|
|
boxDisp.vz = -car_cos->cog.vz;
|
|
|
|
|
|
|
|
gte_ldv0(&boxDisp);
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-09-29 16:00:01 +02:00
|
|
|
gte_rtv0tr();
|
|
|
|
|
|
|
|
gte_stlvnl(&cd[1].x);
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (cp1->controlType != CONTROL_TYPE_NONE &&
|
|
|
|
ABS(cp1->hd.where.t[1] + pPos->vy) < 500 &&
|
2020-12-08 19:41:43 +01:00
|
|
|
bcollided2d(cd))
|
2020-09-29 16:00:01 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
if (bQuick != 0)
|
|
|
|
return 1;
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (FIXEDH(cp1->hd.wheel_speed) > 50)
|
|
|
|
return 1;
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
bFindCollisionPoint(cd, &collisionResult);
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
collisionResult.surfNormal.vy = 0;
|
|
|
|
collisionResult.hit.vy = pcdTanner->hd.where.t[1] + 60;
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
pcdTanner->hd.where.t[0] += FIXEDH(collisionResult.penetration * -collisionResult.surfNormal.vx);
|
|
|
|
pcdTanner->hd.where.t[2] += FIXEDH(collisionResult.penetration * -collisionResult.surfNormal.vz);
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
lever[0] = collisionResult.hit.vx - pcdTanner->hd.where.t[0];
|
|
|
|
lever[1] = collisionResult.hit.vy - pcdTanner->hd.where.t[1];
|
|
|
|
lever[2] = collisionResult.hit.vz - pcdTanner->hd.where.t[2];
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
pointVel[0] = FIXEDH(pcdTanner->st.n.angularVelocity[1] * lever[2] - pcdTanner->st.n.angularVelocity[2] * lever[1]) + pcdTanner->st.n.linearVelocity[0];
|
|
|
|
pointVel[2] = FIXEDH(pcdTanner->st.n.angularVelocity[0] * lever[1] - pcdTanner->st.n.angularVelocity[1] * lever[0]) + pcdTanner->st.n.linearVelocity[2];
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-20 11:52:19 +02:00
|
|
|
strikeVel = (pointVel[0] / 256) * (-collisionResult.surfNormal.vx / 16) +
|
|
|
|
(pointVel[2] / 256) * (-collisionResult.surfNormal.vz / 16);
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (strikeVel < 0)
|
|
|
|
{
|
|
|
|
int lever_dot_n; // $a0
|
|
|
|
int displacementsquared; // $a1
|
|
|
|
int denom; // $a0
|
|
|
|
int twistRateY;
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
twistRateY = car_cos->twistRateY;
|
|
|
|
|
|
|
|
lever_dot_n = FIXEDH(lever[0] * -collisionResult.surfNormal.vx + lever[2] * -collisionResult.surfNormal.vz);
|
2020-10-20 11:52:19 +02:00
|
|
|
displacementsquared = FIXEDH(((lever[0] * lever[0] + lever[2] * lever[2]) - lever_dot_n * lever_dot_n) * twistRateY) + ONE;
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-20 11:52:19 +02:00
|
|
|
if (-strikeVel < 520193)
|
|
|
|
denom = (strikeVel * -ONE) / displacementsquared;
|
2020-10-11 15:38:07 +02:00
|
|
|
else
|
2020-10-20 11:52:19 +02:00
|
|
|
denom = -strikeVel / displacementsquared * ONE;
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-20 11:52:19 +02:00
|
|
|
denom /= 64;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-20 11:52:19 +02:00
|
|
|
reaction[0] = denom * (-collisionResult.surfNormal.vx / 64);
|
|
|
|
reaction[2] = denom * (-collisionResult.surfNormal.vz / 64);
|
2020-10-11 15:38:07 +02:00
|
|
|
|
|
|
|
pcdTanner->st.n.linearVelocity[0] += pcdTanner->st.n.linearVelocity[0] + reaction[0];
|
|
|
|
pcdTanner->st.n.linearVelocity[2] += pcdTanner->st.n.linearVelocity[2] + reaction[2];
|
2020-05-24 10:36:48 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
pcdTanner->hd.aacc[2] -= FIXEDH(lever[1] * reaction[0]);
|
|
|
|
pcdTanner->hd.aacc[0] += FIXEDH(lever[1] * reaction[2]);
|
|
|
|
pcdTanner->hd.aacc[1] += FIXEDH(lever[2] * reaction[0]) - FIXEDH(lever[0] * reaction[2]);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 15:38:07 +02:00
|
|
|
|
|
|
|
pcdTanner->hd.where.t[0] -= FIXEDH(pcdTanner->st.n.linearVelocity[0]);
|
|
|
|
pcdTanner->hd.where.t[2] -= FIXEDH(pcdTanner->st.n.linearVelocity[2]);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-24 10:36:48 +02:00
|
|
|
cp1--;
|
|
|
|
} while (cp1 >= car_data);
|
|
|
|
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
int PingOutPed(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-15 12:33:29 +02:00
|
|
|
int pz;
|
|
|
|
int px;
|
|
|
|
int ps;
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
px = pPed->position.vx - player[0].pos[0];
|
|
|
|
pz = pPed->position.vz - player[0].pos[2];
|
2020-05-15 12:33:29 +02:00
|
|
|
|
|
|
|
ps = px * px + pz * pz;
|
|
|
|
|
|
|
|
if (ps <= 20496 * 20496)
|
|
|
|
return (-player[0].pos[1] - pPed->position.vy < 513) ^ 1;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
|
|
|
return 1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
void SetupCivJump(PEDESTRIAN* pPed, CAR_DATA* cp)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int dz;
|
2020-05-15 12:33:29 +02:00
|
|
|
short scale;
|
2020-10-11 15:38:07 +02:00
|
|
|
int dx;
|
|
|
|
short angle;
|
2020-12-08 17:45:14 +01:00
|
|
|
LONGVECTOR4 dir;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
|
|
|
if (pPed->type != PED_ACTION_JUMP)
|
|
|
|
{
|
|
|
|
pPed->frame1 = 0;
|
|
|
|
pPed->speed = 30;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-05-15 12:33:29 +02:00
|
|
|
if (cp == &car_data[player[0].playerCarId])
|
|
|
|
{
|
|
|
|
if (player[0].horn.on != 0)
|
2020-04-03 00:44:09 +02:00
|
|
|
scale = 0x800;
|
2020-10-11 15:38:07 +02:00
|
|
|
else
|
|
|
|
scale = 0x1000;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
|
|
|
NoteFelony(&felonyData, 1, scale);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_JUMP;
|
2020-10-11 15:38:07 +02:00
|
|
|
pPed->flags |= 0x10;
|
2020-05-15 12:33:29 +02:00
|
|
|
pPed->fpAgitatedState = CivPedJump;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupPedMotionData(pPed);
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (cp == NULL)
|
2020-05-15 12:33:29 +02:00
|
|
|
{
|
|
|
|
if (bAvoidTanner == 0)
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
angle = ratan2(pPed->position.vx - explosion[bAvoidBomb].pos.vx, pPed->position.vz - explosion[bAvoidBomb].pos.vz) - 2048;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 12:33:29 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
dx = player[0].pPed->position.vx - pPed->position.vx;
|
|
|
|
dz = player[0].pPed->position.vz - pPed->position.vz;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
dir[0] = player[0].pPed->speed * rcossin_tbl[(player[0].pPed->dir.vy - 0x800U & 0xfff) * 2 + 1];
|
|
|
|
dir[2] = player[0].pPed->speed * rcossin_tbl[(player[0].pPed->dir.vy - 0x800U & 0xfff) * 2];
|
|
|
|
|
2020-05-15 12:33:29 +02:00
|
|
|
// [A] fuck....
|
2020-10-11 15:38:07 +02:00
|
|
|
if (FIXED(-dir[0]) * dx + FIXED(dir[2]) * dz + 0x800 < 0)
|
|
|
|
angle = -1024;
|
|
|
|
else
|
|
|
|
angle = 1024;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
angle += player[0].pPed->dir.vy;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-15 12:33:29 +02:00
|
|
|
else
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
dx = cp->hd.where.t[0] - pPed->position.vx;
|
|
|
|
dz = cp->hd.where.t[2] - pPed->position.vz;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (cp->st.n.linearVelocity[2] != 0 || cp->st.n.linearVelocity[0] != 0)
|
2020-05-15 12:33:29 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int carVelDisp;
|
|
|
|
carVelDisp = (cp->st.n.linearVelocity[2] * dx - cp->st.n.linearVelocity[0] * dz + 2048);
|
|
|
|
|
|
|
|
angle = ((short)~(ushort)(carVelDisp >> 0x1c) >> 0xf & 0x800U) - ratan2(cp->st.n.linearVelocity[2], cp->st.n.linearVelocity[0]);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 12:33:29 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
angle = ratan2(dz, dx);;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
pPed->dir.vy = angle & 0xfff;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void CivPedJump(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-15 12:33:29 +02:00
|
|
|
if (pPed->frame1 == 2)
|
2020-10-11 15:38:07 +02:00
|
|
|
pPed->speed *= 2;
|
2020-05-15 12:33:29 +02:00
|
|
|
else if (pPed->frame1 == 14)
|
2020-10-11 15:38:07 +02:00
|
|
|
pPed->speed /= 2;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
AnimatePed(pPed);
|
2020-05-15 12:33:29 +02:00
|
|
|
|
|
|
|
if (pPed->frame1 > 29)
|
|
|
|
{
|
|
|
|
pPed->frame1 = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
pPed->type = PED_ACTION_CIVWALK;
|
2020-05-15 12:33:29 +02:00
|
|
|
pPed->fpRestState = CivPedWalk;
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupPedMotionData(pPed);
|
2020-05-15 12:33:29 +02:00
|
|
|
|
|
|
|
pPed->fpAgitatedState = NULL;
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x10;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void SetupCivPedWalk(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-15 12:33:29 +02:00
|
|
|
pPed->flags |= 0x10;
|
|
|
|
|
2020-06-28 22:27:46 +02:00
|
|
|
if (pPed->type == PED_ACTION_CIVRUN)
|
2020-05-15 12:33:29 +02:00
|
|
|
pPed->speed = 30;
|
|
|
|
else
|
|
|
|
pPed->speed = 10;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
|
|
|
SetupPedMotionData(pPed);
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-05-15 12:33:29 +02:00
|
|
|
pPed->frame1 = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void CivPedWalk(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int dir;
|
2020-04-03 00:44:09 +02:00
|
|
|
int turn;
|
|
|
|
|
2020-05-15 12:33:29 +02:00
|
|
|
if ((pPed->flags & 0x10U) == 0)
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupCivPedWalk(pPed);
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (pPed->finished_turn == 9)
|
|
|
|
dir = pPed->dir.vy + 2048;
|
|
|
|
else
|
|
|
|
dir = pPed->dir.vy + 1850;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
|
|
|
if ((pPed->flags & 2U) == 0)
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
if (IsPavement(pPed->position.vx + (rcossin_tbl[(dir & 0xfff) * 2] >> 5),
|
|
|
|
pPed->position.vy,
|
|
|
|
pPed->position.vz + (rcossin_tbl[(dir & 0xfff) * 2 + 1] >> 5), pPed) == 0)
|
2020-05-15 12:33:29 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
if (pPed->finished_turn == 9)
|
2020-06-21 03:12:38 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
dir = pPed->dir.vy + 0xa00U & 0xfff;
|
|
|
|
|
|
|
|
if (IsPavement(
|
|
|
|
pPed->position.vx + FIXED(rcossin_tbl[dir * 2] * 0x80),
|
|
|
|
pPed->position.vy,
|
|
|
|
pPed->position.vz + FIXED(rcossin_tbl[dir * 2 + 1] * 0x80), NULL) == 0)
|
|
|
|
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags &= ~0x2000;
|
2020-05-15 12:33:29 +02:00
|
|
|
else
|
2020-06-22 20:29:02 +02:00
|
|
|
pPed->flags |= 0x2000;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (pPed->flags & 0x2000)
|
2020-05-15 12:33:29 +02:00
|
|
|
turn = 128;
|
2020-10-11 15:38:07 +02:00
|
|
|
else
|
|
|
|
turn = -128;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->doing_turn < 32)
|
2020-05-15 12:33:29 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
SetPedestrianTurn(pPed, turn);
|
2020-05-15 12:33:29 +02:00
|
|
|
pPed->doing_turn++;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 12:33:29 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
dir = pPed->dir.vy + 0x800U & 0xfff;
|
|
|
|
|
|
|
|
pPed->velocity.vx = FIXED(pPed->speed * rcossin_tbl[dir * 2]);
|
|
|
|
pPed->velocity.vz = FIXED(pPed->speed * rcossin_tbl[dir * 2 + 1]);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:33:29 +02:00
|
|
|
pPed->finished_turn = 0;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:33:29 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pPed->doing_turn = 0;
|
|
|
|
|
|
|
|
if (pPed->finished_turn++ > 8)
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
pPed->dir.vy += 0x200U & 0xfc00;
|
|
|
|
|
|
|
|
dir = pPed->dir.vy + 0x800U & 0xfff;
|
|
|
|
|
|
|
|
pPed->velocity.vx = FIXED(pPed->speed * rcossin_tbl[dir * 2]);
|
|
|
|
pPed->velocity.vz = FIXED(pPed->speed * rcossin_tbl[dir * 2 + 1]);
|
|
|
|
|
2020-05-15 12:33:29 +02:00
|
|
|
pPed->finished_turn = 9;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-05-15 12:33:29 +02:00
|
|
|
{
|
|
|
|
pPed->speed = 0;
|
2020-10-11 15:38:07 +02:00
|
|
|
pPed->dir.vy += pPed->head_rot;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
AnimatePed(pPed);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void CivPedSit(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-15 12:33:29 +02:00
|
|
|
pPed->frame1 = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void HandlePedestrians(void)
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
if (gInGameCutsceneActive != 0 || NumPlayers != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BuildCarCollisionBox();
|
|
|
|
ControlPedestrians();
|
|
|
|
PingInPedestrians();
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void PedestrianActionInit_WalkToTarget(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-15 12:33:29 +02:00
|
|
|
int dir;
|
|
|
|
dir = CalcPedestrianDirection(0, (pPed->position).vx, (pPed->position).vz, &pPed->target);
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (dir == 0)
|
|
|
|
return;
|
2020-05-15 12:33:29 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
pPed->last_dir = dir;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (dir == 1)
|
|
|
|
pPed->dir.vy = 1024;
|
|
|
|
else if (dir == 2)
|
|
|
|
pPed->dir.vy = 3072;
|
|
|
|
else if (dir == 4)
|
|
|
|
pPed->dir.vy = 0;
|
|
|
|
else if (dir == 8)
|
|
|
|
pPed->dir.vy = 2048;
|
|
|
|
|
|
|
|
CorrectPathPosition(pPed, (VECTOR*)&pPed->position);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void CorrectPathPosition(PEDESTRIAN* pedestrian, VECTOR* position)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
int CalcPedestrianDirection(int last_dir, int wx, int wz, VECTOR* target)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int num;
|
|
|
|
int rx;
|
|
|
|
int rz;
|
|
|
|
int dir;
|
|
|
|
int mask;
|
|
|
|
int cnt;
|
|
|
|
|
|
|
|
mask = pedestrian_roads.west == -20;
|
|
|
|
dir = mask;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pedestrian_roads.east == -20)
|
2020-05-15 12:41:49 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
mask |= 2;
|
|
|
|
dir++;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:41:49 +02:00
|
|
|
|
|
|
|
if (pedestrian_roads.north == -20)
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
mask |= 4;
|
|
|
|
dir++;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:41:49 +02:00
|
|
|
|
|
|
|
if (pedestrian_roads.south == -20)
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
mask |= 8;
|
|
|
|
dir++;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
num = mask & last_dir;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (num == 0)
|
2020-05-15 12:41:49 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
if(dir > 1)
|
|
|
|
{
|
|
|
|
num = 16;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
cnt = Random2(0) % dir + 1;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
while (cnt != 0)
|
|
|
|
{
|
|
|
|
num >>= 1;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (mask & num)
|
|
|
|
cnt--;
|
|
|
|
}
|
|
|
|
|
|
|
|
num = mask & num;
|
|
|
|
}
|
|
|
|
else
|
2020-05-15 12:41:49 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
num = mask;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
rx = wx & 0xfffffc00;
|
|
|
|
rz = wz & 0xfffffc00;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (num == 1)
|
2020-05-15 12:41:49 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
target->vx = rx - 512;
|
|
|
|
target->vz = rz + 512;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 15:38:07 +02:00
|
|
|
else if (num == 2)
|
2020-05-15 12:41:49 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
target->vx = rx + 1536;
|
|
|
|
target->vz = rz + 512;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 15:38:07 +02:00
|
|
|
else if (num == 4)
|
|
|
|
{
|
|
|
|
target->vx = rx + 512;
|
|
|
|
target->vz = rz + 1536;
|
|
|
|
}
|
|
|
|
else if (num == 8)
|
|
|
|
{
|
|
|
|
target->vx = rx + 512;
|
|
|
|
target->vz = rz - 512;
|
|
|
|
}
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
target->vy = 0;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
|
|
|
return num;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
int IsPavement(int x, int y, int z, PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-15 12:41:49 +02:00
|
|
|
int r;
|
|
|
|
VECTOR v;
|
|
|
|
|
|
|
|
v.vy = -y;
|
|
|
|
v.vx = x;
|
|
|
|
v.vz = z;
|
|
|
|
r = GetSurfaceIndex(&v);
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (r == -20)
|
2020-05-15 12:41:49 +02:00
|
|
|
return (RoadInCell(&v) != 0);
|
2020-10-11 15:38:07 +02:00
|
|
|
|
|
|
|
if (pPed)
|
2020-05-15 12:41:49 +02:00
|
|
|
{
|
|
|
|
if (r != -26 && r != -23 && r != -32)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
pPed->flags |= 1;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:41:49 +02:00
|
|
|
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void SetPedestrianTurn(PEDESTRIAN* pedestrian, int turn)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int speed;
|
|
|
|
int dir;
|
|
|
|
|
|
|
|
dir = pedestrian->dir.vy + turn & 0xfff;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
pedestrian->dir.vy = dir;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-17 17:46:39 +02:00
|
|
|
dir = dir + 0x800 & 0xfff;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
pedestrian->position.vz -= pedestrian->velocity.vz;
|
|
|
|
pedestrian->position.vx -= pedestrian->velocity.vx;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
speed = pedestrian->speed;
|
|
|
|
|
|
|
|
pedestrian->velocity.vx = FIXEDH(speed * rcossin_tbl[dir * 2]);
|
|
|
|
pedestrian->velocity.vz = FIXEDH(speed * rcossin_tbl[dir * 2 + 1]);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
SEATED_PEDESTRIANS* FindSeated(void)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int dz;
|
|
|
|
int dx;
|
|
|
|
int count1;
|
2020-10-11 12:19:12 +02:00
|
|
|
SEATED_PEDESTRIANS* seatedptr;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (!seated_pedestrian)
|
|
|
|
return NULL;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (seated_pedestrian->rotation == 9999)
|
|
|
|
return NULL;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
count1 = 3;
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
seatedptr = seated_pedestrian + seated_count;
|
|
|
|
seated_count++;
|
|
|
|
|
|
|
|
if (seatedptr->rotation == 9999)
|
|
|
|
{
|
|
|
|
seated_count = 0;
|
|
|
|
seatedptr = seated_pedestrian;
|
|
|
|
}
|
2020-05-15 12:41:49 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
dx = FIXED(seatedptr->x - player[0].pos[0]);
|
|
|
|
dz = FIXED(seatedptr->z - player[0].pos[2]);
|
|
|
|
|
|
|
|
if (seatedptr->index == 0)
|
|
|
|
{
|
|
|
|
count1--;
|
|
|
|
|
|
|
|
if((dx * dx + dz * dz) - 11U < 29)
|
2020-05-15 12:41:49 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
add_seated(seatedptr, seated_count);
|
|
|
|
return seatedptr;
|
|
|
|
}
|
2020-10-11 15:38:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} while (count1 != 0);
|
2020-05-15 12:41:49 +02:00
|
|
|
|
|
|
|
return NULL;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
SEATED_PEDESTRIANS* FindTannerASeat(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int dx, dz;
|
|
|
|
int distSqr;
|
|
|
|
int bestSqr;
|
2020-10-11 12:19:12 +02:00
|
|
|
SEATED_PEDESTRIANS* seatedptr;
|
|
|
|
SEATED_PEDESTRIANS* theOne;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-05-15 12:54:05 +02:00
|
|
|
theOne = NULL;
|
2020-10-11 15:38:07 +02:00
|
|
|
bestSqr = 4096;
|
2020-04-03 00:44:09 +02:00
|
|
|
seated_count = 0;
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (seated_pedestrian->rotation != 9999)
|
2020-05-15 12:54:05 +02:00
|
|
|
{
|
|
|
|
seatedptr = seated_pedestrian;
|
2020-04-03 00:44:09 +02:00
|
|
|
seated_count = 0;
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
dx = ABS(seatedptr->x - pPed->position.vx);
|
|
|
|
dz = ABS(seatedptr->z - pPed->position.vz);
|
|
|
|
|
|
|
|
seated_count++;
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (dx < 900 && dz < 900)
|
2020-05-15 12:54:05 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
distSqr = FIXED(dx * dx + dz * dz);
|
|
|
|
|
|
|
|
if(distSqr < bestSqr)
|
|
|
|
{
|
|
|
|
theOne = seatedptr;
|
|
|
|
bestSqr = distSqr;
|
|
|
|
}
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:54:05 +02:00
|
|
|
|
|
|
|
seatedptr++;
|
|
|
|
} while (seatedptr->rotation != 9999);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (bestSqr < 6 && theOne)
|
2020-05-15 12:54:05 +02:00
|
|
|
{
|
|
|
|
pPed->dir.vy = theOne->rotation;
|
|
|
|
pPed->position.vx = theOne->x;
|
|
|
|
pPed->position.vz = theOne->z;
|
|
|
|
|
|
|
|
return theOne;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-05-15 12:54:05 +02:00
|
|
|
|
|
|
|
return NULL;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void add_seated(SEATED_PEDESTRIANS* seatedptr, int seat_index)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
PEDESTRIAN* pedptr;
|
2020-12-08 18:12:17 +01:00
|
|
|
int rnd;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-10-20 12:17:12 +02:00
|
|
|
if (num_pedestrians < MAX_SEATED_PEDS)
|
2020-05-15 12:54:05 +02:00
|
|
|
{
|
|
|
|
pedptr = CreatePedestrian();
|
|
|
|
|
|
|
|
if (!pedptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
seatedptr->index = 2;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pedptr->type = PED_ACTION_CIVSIT;
|
2020-05-15 12:54:05 +02:00
|
|
|
pedptr->speed = 0;
|
|
|
|
pedptr->velocity.vx = 0;
|
|
|
|
pedptr->velocity.vy = 0;
|
|
|
|
pedptr->velocity.vz = 0;
|
|
|
|
pedptr->dir.vy = seatedptr->rotation;
|
|
|
|
pedptr->position.vx = seatedptr->x;
|
|
|
|
pedptr->position.vz = seatedptr->z;
|
|
|
|
pedptr->position.vy = player[0].pos[1];
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
pedptr->position.vy = -75 - MapHeight((VECTOR*)&pedptr->position);
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
pedptr->index = 1;
|
2020-10-11 15:38:07 +02:00
|
|
|
pedptr->seat_index = seat_index;
|
2020-04-03 00:44:09 +02:00
|
|
|
pedptr->pedType = CIVILIAN;
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
SetupPedestrian(pedptr);
|
2020-05-15 12:54:05 +02:00
|
|
|
|
|
|
|
pedptr->fpAgitatedState = NULL;
|
|
|
|
pedptr->fpRestState = CivPedSit;
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
pedptr->pallet = (Random2(0) % 5) + (Random2(0) % 5) * 16;
|
|
|
|
rnd = Random2(0);
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if ((rnd / 6) * 6 == rnd - 3)
|
2020-05-15 12:54:05 +02:00
|
|
|
pedptr->flags |= 0x4000;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-07-05 18:32:12 +02:00
|
|
|
CAR_COLLISION_BOX collision_box[8];
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* collision_car_ptr[8];
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2021-04-04 11:24:16 +02:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
void set_coll_box(int index, CAR_DATA* cp, int offset)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int isPlayerCar;
|
|
|
|
int boxSize;
|
|
|
|
|
2020-07-05 18:32:12 +02:00
|
|
|
VECTOR BoxCentre;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (index >= 8)
|
2020-04-03 00:44:09 +02:00
|
|
|
return;
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
boxSize = 400;
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
isPlayerCar = (cp == &car_data[player[0].playerCarId]);
|
|
|
|
|
|
|
|
if (player[0].horn.on)
|
2020-07-05 18:32:12 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
if (isPlayerCar)
|
|
|
|
boxSize = 1200;
|
|
|
|
else
|
|
|
|
boxSize = 260;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (!isPlayerCar)
|
|
|
|
boxSize -= 140;
|
2020-07-05 18:32:12 +02:00
|
|
|
|
|
|
|
collision_car_ptr[index] = cp;
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
BoxCentre.vx = cp->hd.where.t[0] + (cp->st.n.linearVelocity[0] >> (offset & 0x1fU));
|
|
|
|
BoxCentre.vz = cp->hd.where.t[2] + (cp->st.n.linearVelocity[2] >> (offset & 0x1fU));
|
|
|
|
|
|
|
|
collision_box[index].min_x = BoxCentre.vx - boxSize;
|
|
|
|
collision_box[index].min_z = BoxCentre.vz - boxSize;
|
|
|
|
collision_box[index].max_x = BoxCentre.vx + boxSize;
|
|
|
|
collision_box[index].max_z = BoxCentre.vz + boxSize;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-07-05 18:32:12 +02:00
|
|
|
CAR_COLLISION_BOX extra_collision_boxes[5];
|
|
|
|
CAR_COLLISION_BOX tanner_collision_box;
|
|
|
|
int num_extra_boxes_set;
|
|
|
|
int collision_boxes_set;
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void BuildCarCollisionBox(void)
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
CAR_COLLISION_BOX* cbox;
|
|
|
|
int dir;
|
|
|
|
int vx, vz;
|
2020-04-03 00:44:09 +02:00
|
|
|
int index;
|
2020-10-31 01:11:58 +01:00
|
|
|
EXOBJECT* expl;
|
|
|
|
CAR_DATA* cp;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
if (player[0].playerCarId != -1) // [A] ASan bug fix
|
2020-08-11 16:39:40 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
set_coll_box(0, &car_data[player[0].playerCarId], 8);
|
|
|
|
set_coll_box(1, &car_data[player[0].playerCarId], 9);
|
2020-08-11 16:39:40 +02:00
|
|
|
}
|
|
|
|
|
2020-10-20 12:17:12 +02:00
|
|
|
cp = &car_data[(CameraCnt & 3)];
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
collision_boxes_set = 2;
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-20 12:17:12 +02:00
|
|
|
while (cp < &car_data[MAX_CARS])
|
2020-10-11 15:38:07 +02:00
|
|
|
{
|
|
|
|
if (cp != &car_data[player[0].playerCarId] && cp->controlType != CONTROL_TYPE_NONE)
|
|
|
|
{
|
|
|
|
set_coll_box(collision_boxes_set, cp, 8);
|
|
|
|
collision_boxes_set++;
|
|
|
|
}
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
cp += 4; // [A] WTF?
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-07-05 18:32:12 +02:00
|
|
|
|
|
|
|
if (player[0].playerType == 2)
|
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
dir = player[0].pPed->dir.vy - 0x800U & 0xfff;
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
vx = FIXED(player[0].pPed->speed * rcossin_tbl[dir * 2] * 4);
|
|
|
|
vz = FIXED(player[0].pPed->speed * rcossin_tbl[dir * 2 + 1] * 4);
|
|
|
|
|
|
|
|
tanner_collision_box.min_x = player[0].pPed->position.vx + vx - 148;
|
|
|
|
tanner_collision_box.max_x = player[0].pPed->position.vx + vx + 148;
|
|
|
|
tanner_collision_box.min_z = player[0].pPed->position.vz + vz - 148;
|
|
|
|
tanner_collision_box.max_z = player[0].pPed->position.vz + vz + 148;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
num_extra_boxes_set = 0;
|
2020-10-11 15:38:07 +02:00
|
|
|
expl = explosion;
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
index = 4;
|
2020-10-11 15:38:07 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (expl->time >= 2048)
|
|
|
|
{
|
|
|
|
cbox = extra_collision_boxes + num_extra_boxes_set;
|
|
|
|
|
|
|
|
cbox->min_x = expl->pos.vx - 1952;
|
|
|
|
cbox->max_x = expl->pos.vx + 1952;
|
|
|
|
|
|
|
|
cbox->min_z = expl->pos.vz - 1952;
|
|
|
|
cbox->max_z = expl->pos.vz + 1952;
|
|
|
|
|
|
|
|
num_extra_boxes_set++;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 15:38:07 +02:00
|
|
|
|
|
|
|
index--;
|
|
|
|
expl++;
|
|
|
|
} while (index > -1);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* CheckForCar(PEDESTRIAN* pedestrian)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
int count;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
count = 0;
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
while (count < collision_boxes_set)
|
|
|
|
{
|
|
|
|
if (CheckForPlayerCar(pedestrian, &collision_box[count]) != 0)
|
|
|
|
return collision_car_ptr[count];
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
count++;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-07-05 18:32:12 +02:00
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
count = 0;
|
|
|
|
while (count < num_extra_boxes_set)
|
2020-07-05 18:32:12 +02:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
if (CheckForPlayerCar(pedestrian, &extra_collision_boxes[count]))
|
|
|
|
{
|
|
|
|
bAvoidBomb = count;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
count++;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-07-05 18:32:12 +02:00
|
|
|
|
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (player[0].playerType == 2 && CheckForPlayerCar(pedestrian, &tanner_collision_box) != 0)
|
2020-04-03 00:44:09 +02:00
|
|
|
bAvoidTanner = 1;
|
2020-07-05 18:32:12 +02:00
|
|
|
|
|
|
|
return NULL;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
int CheckForPlayerCar(PEDESTRIAN* pedestrian, CAR_COLLISION_BOX* collision_box)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 15:38:07 +02:00
|
|
|
if (pedestrian->position.vx >= collision_box->min_x &&
|
|
|
|
pedestrian->position.vx <= collision_box->max_x &&
|
|
|
|
pedestrian->position.vz >= collision_box->min_z &&
|
|
|
|
pedestrian->position.vz <= collision_box->max_z)
|
|
|
|
{
|
|
|
|
return 1;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-10-11 15:38:07 +02:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-05-15 12:54:05 +02:00
|
|
|
int basic_car_interest;
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void CalculatePedestrianInterest(PEDESTRIAN* pPed)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA* pCar;
|
2020-09-08 15:43:00 +02:00
|
|
|
int carId;
|
|
|
|
int interest;
|
2020-09-03 21:13:35 +02:00
|
|
|
VECTOR v1;
|
|
|
|
VECTOR v2;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2020-09-08 15:43:00 +02:00
|
|
|
carId = player[0].playerCarId;
|
2020-08-11 16:39:40 +02:00
|
|
|
|
2020-09-03 21:13:35 +02:00
|
|
|
if (carId == -1) // [A] ASan bug fix
|
2020-10-20 21:11:00 +02:00
|
|
|
{
|
|
|
|
pPed->head_rot = 0;
|
2020-08-11 16:39:40 +02:00
|
|
|
return;
|
2020-10-20 21:11:00 +02:00
|
|
|
}
|
2020-08-11 16:39:40 +02:00
|
|
|
|
2020-09-08 15:43:00 +02:00
|
|
|
pCar = &car_data[carId];
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-09-08 15:43:00 +02:00
|
|
|
basic_car_interest = (pCar->hd.wheel_speed >> 10) + pCar->totalDamage;
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-09-03 21:13:35 +02:00
|
|
|
v1.vx = pPed->position.vx - pCar->hd.where.t[0];
|
2020-09-08 15:43:00 +02:00
|
|
|
v1.vz = pPed->position.vz - pCar->hd.where.t[2];
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-09-03 21:13:35 +02:00
|
|
|
v2.vx = (v1.vx < 0) ? -v1.vx : v1.vx;
|
2020-09-08 15:43:00 +02:00
|
|
|
v2.vz = (v1.vz < 0) ? -v1.vz : v1.vz;
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-09-08 15:43:00 +02:00
|
|
|
int dist = (v2.vx + v2.vz);
|
2020-09-03 21:13:35 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (dist < 6001)
|
2020-09-08 15:43:00 +02:00
|
|
|
interest = 6000 - dist;
|
2020-10-11 12:19:12 +02:00
|
|
|
else
|
2020-09-08 15:43:00 +02:00
|
|
|
interest = 0;
|
2020-05-15 12:54:05 +02:00
|
|
|
|
2020-10-11 12:19:12 +02:00
|
|
|
if (pPed->type == PED_ACTION_JUMP)
|
2020-05-15 12:54:05 +02:00
|
|
|
{
|
2020-09-08 15:43:00 +02:00
|
|
|
pPed->head_rot = pPed->dir.vy + ratan2(v1.vz, v1.vx) + 3072 & 0xfff;
|
|
|
|
return;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-09-08 15:43:00 +02:00
|
|
|
|
|
|
|
if (interest + basic_car_interest > 2999)
|
2020-05-15 12:54:05 +02:00
|
|
|
{
|
2020-09-08 15:43:00 +02:00
|
|
|
pPed->interest = interest + basic_car_interest;
|
|
|
|
pPed->head_rot = pPed->dir.vy + ratan2(v1.vz, v1.vx) + 3072 & 0xfff;
|
|
|
|
|
|
|
|
if (pPed->head_rot - 897U > 2302)
|
|
|
|
return;
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-09-03 21:13:35 +02:00
|
|
|
|
2020-09-08 15:43:00 +02:00
|
|
|
pPed->head_rot = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:38:07 +02:00
|
|
|
// [D] [T]
|
2020-10-11 12:19:12 +02:00
|
|
|
void ProcessChairLump(char* lump_file, int lump_size)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-11 12:19:12 +02:00
|
|
|
seated_pedestrian = (SEATED_PEDESTRIANS*)lump_file;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
// [D] [T]
|
|
|
|
// Havana easter egg.
|
|
|
|
void IHaveThePower(void)
|
|
|
|
{
|
|
|
|
CAR_DATA* cp;
|
|
|
|
LONGVECTOR4 force = { 0x9000, 0, 0, 0 };
|
|
|
|
LONGVECTOR4 point = { 0, 0, 90, 0 };
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
if (GameLevel != 1)
|
|
|
|
return;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
if (player[0].pos[0] > -231749 || player[0].pos[0] < -232147 ||
|
|
|
|
player[0].pos[2] < -236229 || player[0].pos[2] > -235831)
|
|
|
|
{
|
|
|
|
// if player gets out the zone, restore weather back
|
|
|
|
if (bPower != 0)
|
|
|
|
{
|
|
|
|
bPower = 0;
|
|
|
|
gWeather = oldWeather;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
if (tannerPad & TANNER_PAD_POWER)
|
|
|
|
{
|
|
|
|
if (bPower == 0)
|
|
|
|
{
|
|
|
|
oldWeather = gWeather;
|
|
|
|
bPower = 1;
|
|
|
|
gWeather = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
powerCounter++;
|
|
|
|
|
|
|
|
// make cars go crazy
|
|
|
|
if (powerCounter < 20)
|
|
|
|
{
|
|
|
|
cp = car_data;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (cp->controlType != CONTROL_TYPE_NONE)
|
|
|
|
{
|
|
|
|
cp->hd.acc[0] += force[0];
|
|
|
|
cp->hd.acc[1] += force[1];
|
|
|
|
cp->hd.acc[2] += force[2];
|
|
|
|
|
|
|
|
cp->hd.aacc[0] += FIXEDH(point[1] * force[2] - point[2] * force[1]);
|
|
|
|
cp->hd.aacc[1] += FIXEDH(point[2] * force[0] - point[0] * force[2]);
|
|
|
|
cp->hd.aacc[2] += FIXEDH(point[0] * force[1] - point[1] * force[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
cp++;
|
|
|
|
} while (cp < &car_data[MAX_CARS]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (powerCounter > 48)
|
|
|
|
powerCounter = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [D] [T]
|
2021-04-04 21:33:43 +02:00
|
|
|
void ProcessTannerPad(PEDESTRIAN* pPed, u_int pad, char PadSteer, char use_analogue)
|
2020-12-09 09:33:57 +01:00
|
|
|
{
|
|
|
|
sdPlane* SurfacePtr;
|
|
|
|
int direction;
|
|
|
|
VECTOR vec;
|
|
|
|
VECTOR normal;
|
|
|
|
VECTOR out;
|
|
|
|
VECTOR tVec;
|
|
|
|
sdPlane* plane;
|
|
|
|
PLAYER* lcp;
|
|
|
|
|
|
|
|
int padId;
|
|
|
|
|
|
|
|
padId = ABS(pPed->padId);
|
|
|
|
plane = NULL;
|
|
|
|
|
|
|
|
lcp = &player[padId];
|
|
|
|
|
|
|
|
// don't move dead Tanner
|
|
|
|
if (lcp->dying != 0)
|
|
|
|
tannerPad = 0;
|
|
|
|
else
|
|
|
|
tannerPad = pad;
|
|
|
|
|
|
|
|
if (use_analogue)
|
|
|
|
{
|
|
|
|
tannerPad = pad;
|
|
|
|
|
|
|
|
if (PadSteer != 0)
|
|
|
|
tannerPad |= (PadSteer < 0) ? TANNER_PAD_TURNLEFT : TANNER_PAD_TURNRIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
IHaveThePower(); // process Havana easter egg near the entrance cemetery
|
|
|
|
|
|
|
|
vec.vx = pPed->position.vx;
|
|
|
|
vec.vy = -pPed->position.vy;
|
|
|
|
vec.vz = pPed->position.vz;
|
|
|
|
|
|
|
|
direction = pPed->dir.vy - 0x800U & 0xfff;
|
|
|
|
|
|
|
|
tVec.vx = vec.vx + (rcossin_tbl[direction * 2] * 5 >> 9);
|
|
|
|
tVec.vy = vec.vy;
|
|
|
|
tVec.vz = vec.vz + (rcossin_tbl[direction * 2 + 1] * 5 >> 9);
|
|
|
|
|
|
|
|
bStopTanner = 0;
|
|
|
|
|
|
|
|
int mapheight[2];
|
|
|
|
|
|
|
|
mapheight[0] = -130 - MapHeight(&vec);
|
|
|
|
mapheight[1] = -130 - MapHeight(&tVec);
|
|
|
|
|
|
|
|
int dist = ABS(mapheight[1] - mapheight[0]);
|
|
|
|
|
|
|
|
// check slope
|
|
|
|
if (dist <= 1010)
|
|
|
|
{
|
|
|
|
SurfacePtr = sdGetCell(&tVec);
|
|
|
|
|
|
|
|
if (SurfacePtr != NULL)
|
|
|
|
{
|
|
|
|
dist = ABS(((SurfacePtr->b >> 2) - 2048 & 0xfff) - 2048);
|
|
|
|
|
|
|
|
if (dist <= 1100)
|
|
|
|
{
|
|
|
|
switch (SurfacePtr->surface)
|
|
|
|
{
|
|
|
|
case -32:
|
|
|
|
break;
|
|
|
|
//case 6: // water. We allow to walk on water in Rio a little bit. Then he drowns
|
|
|
|
case 9: // water with fade out
|
|
|
|
default:
|
|
|
|
dist = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// can't walk in water
|
|
|
|
if (dist != -1)
|
|
|
|
bStopTanner = 1;
|
|
|
|
|
|
|
|
if (pPed->type != PED_ACTION_SIT && !bStopTanner)
|
|
|
|
pPed->position.vy = mapheight[0];
|
|
|
|
|
|
|
|
// "Car Bomb" cutscene
|
|
|
|
if (gInGameCutsceneActive && gCurrentMissionNumber == 23 &&
|
|
|
|
gInGameCutsceneID == 0 && CameraCnt == 459 && pPed->pedType != TANNER_MODEL &&
|
|
|
|
(!ActiveCheats.cheat12 || pPed->pedType != OTHER_MODEL))
|
|
|
|
{
|
|
|
|
lcp->pPed = NULL;
|
|
|
|
lcp->playerType = 0;
|
|
|
|
|
|
|
|
DestroyPedestrian(pPed);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// do actions
|
|
|
|
if (tannerPad & TANNER_PAD_ACTION)
|
|
|
|
{
|
|
|
|
if (gTannerActionNeeded)
|
|
|
|
{
|
|
|
|
// attempt to push a button
|
|
|
|
switch (pPed->type)
|
|
|
|
{
|
|
|
|
case PED_ACTION_GETINCAR:
|
|
|
|
case PED_ACTION_GETOUTCAR:
|
|
|
|
// do not attempt
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// hey, wait -- TANNER!
|
|
|
|
SetupPressButton(pPed);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// priority. Try to get into car first
|
|
|
|
// attempt to get into a car
|
|
|
|
switch (pPed->type)
|
|
|
|
{
|
|
|
|
case PED_ACTION_GETINCAR:
|
|
|
|
case PED_ACTION_GETOUTCAR:
|
|
|
|
// do not attempt
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// enter the nearest car if possible
|
|
|
|
if (!gCantDrive)
|
|
|
|
{
|
|
|
|
DeActivatePlayerPedestrian(pPed);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// attempt to sit down
|
|
|
|
switch (pPed->type)
|
|
|
|
{
|
|
|
|
case PED_ACTION_GETINCAR:
|
|
|
|
case PED_ACTION_GETOUTCAR:
|
|
|
|
case PED_ACTION_SIT:
|
|
|
|
// do not attempt
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// sit his ass down
|
|
|
|
if (FindTannerASeat(pPed) != NULL)
|
|
|
|
{
|
|
|
|
SetupTannerSitDown(pPed);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPed->fpAgitatedState != NULL)
|
|
|
|
(*pPed->fpAgitatedState)(pPed);
|
|
|
|
else
|
|
|
|
(*pPed->fpRestState)(pPed);
|
|
|
|
|
|
|
|
if (lcp->cameraView == 2 && pPed->type != PED_ACTION_GETINCAR)
|
|
|
|
{
|
|
|
|
if (oldCamView != lcp->cameraView)
|
|
|
|
{
|
|
|
|
camAngle.vx = camera_angle.vx;
|
|
|
|
camAngle.vz = camera_angle.vz;
|
|
|
|
}
|
|
|
|
|
|
|
|
camAngle.vy = lcp->headPos - player[0].dir & 0xfff;
|
|
|
|
TannerCameraHandler(pPed);
|
|
|
|
}
|
|
|
|
|
|
|
|
oldCamView = lcp->cameraView;
|
|
|
|
TannerCollision(pPed);
|
|
|
|
|
|
|
|
// chicago bridge slope
|
|
|
|
if (GameLevel == 0)
|
|
|
|
{
|
|
|
|
FindSurfaceD2((VECTOR*)lcp->pos, &normal, &out, &plane);
|
|
|
|
|
|
|
|
if (plane->surface != -1 && plane->surface < 32 && (plane->surface & 0x10))
|
|
|
|
{
|
|
|
|
pPed->position.vx += (normal.vx >> 6);
|
|
|
|
pPed->position.vz += (normal.vz >> 6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// [D] [T]
|
|
|
|
int ActivatePlayerPedestrian(CAR_DATA* pCar, char* padId, int direction, LONGVECTOR4* position, PED_MODEL_TYPES playerType)
|
|
|
|
{
|
|
|
|
int wbody;
|
|
|
|
int side;
|
|
|
|
int dir;
|
|
|
|
PEDESTRIAN* pedptr;
|
|
|
|
int playerId;
|
|
|
|
VECTOR* pos;
|
|
|
|
VECTOR v;
|
2021-05-03 11:11:28 +02:00
|
|
|
int d, y;
|
2020-12-09 09:33:57 +01:00
|
|
|
PLAYER* lp;
|
|
|
|
int x, z;
|
|
|
|
|
|
|
|
if (numTannerPeds > 7)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (padId == NULL)
|
|
|
|
{
|
|
|
|
playerId = GetPlayerId(pCar);
|
|
|
|
lp = &player[playerId];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
playerId = ABS(*padId);
|
|
|
|
|
|
|
|
pedptr = pUsedPeds;
|
|
|
|
|
|
|
|
while (pedptr != NULL)
|
|
|
|
{
|
|
|
|
if (ABS(pedptr->padId) == playerId)
|
|
|
|
{
|
|
|
|
player[playerId].pPed = pedptr;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pedptr = pedptr->pNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
lp = &player[playerId];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pCar == NULL)
|
|
|
|
{
|
|
|
|
x = (*position)[0];
|
|
|
|
z = (*position)[2];
|
|
|
|
|
|
|
|
wbody = 1;
|
|
|
|
|
|
|
|
d = direction;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = pCar->hd.where.t[0];
|
|
|
|
z = pCar->hd.where.t[2];
|
|
|
|
|
|
|
|
y = pCar->hd.where.t[1];
|
|
|
|
d = pCar->hd.direction;
|
|
|
|
|
|
|
|
wbody = car_cosmetics[pCar->ap.model].colBox.vx;
|
|
|
|
}
|
|
|
|
|
|
|
|
wbody += 90;
|
|
|
|
|
2021-05-03 11:11:28 +02:00
|
|
|
dir = d - 2048;
|
|
|
|
|
2020-12-09 09:33:57 +01:00
|
|
|
v.vy = y;
|
|
|
|
v.vx = x - FIXED(wbody * rcossin_tbl[(d & 0xfffU) * 2 + 1]);
|
|
|
|
v.vz = z + FIXED(wbody * rcossin_tbl[(d & 0xfffU) * 2]);
|
|
|
|
|
|
|
|
side = 0;
|
|
|
|
|
|
|
|
if (pCar != NULL)
|
|
|
|
{
|
2021-05-03 11:11:28 +02:00
|
|
|
if (QuickBuildingCollisionCheck(&v, dir, 10, 10, 10) ||
|
|
|
|
TannerCarCollisionCheck(&v, d, 1))
|
2020-12-09 09:33:57 +01:00
|
|
|
{
|
|
|
|
side = 1;
|
|
|
|
|
|
|
|
v.vy = y;
|
|
|
|
|
|
|
|
v.vx = x - FIXED(-wbody * rcossin_tbl[(d & 0xfffU) * 2 + 1]);
|
|
|
|
v.vz = z + FIXED(-wbody * rcossin_tbl[(d & 0xfffU) * 2]);
|
|
|
|
|
2021-05-03 11:11:28 +02:00
|
|
|
if (QuickBuildingCollisionCheck(&v, dir, 10, 10, 10))
|
2020-12-09 09:33:57 +01:00
|
|
|
return 0;
|
2021-05-03 11:11:28 +02:00
|
|
|
|
|
|
|
if (TannerCarCollisionCheck(&v, d, 1))
|
2020-12-09 09:33:57 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pedptr = CreatePedestrian();
|
|
|
|
numTannerPeds++;
|
|
|
|
|
|
|
|
pedptr->interest = 0; // idle timer
|
|
|
|
pedptr->flags &= ~4; // reverse animation
|
|
|
|
|
|
|
|
if (padId == NULL)
|
|
|
|
pedptr->padId = playerId;
|
|
|
|
else
|
|
|
|
pedptr->padId = *padId;
|
|
|
|
|
|
|
|
if (pedptr)
|
|
|
|
pos = (VECTOR*)&pedptr->position;
|
|
|
|
else
|
|
|
|
pos = NULL;
|
|
|
|
|
|
|
|
if (pCar == NULL)
|
|
|
|
{
|
|
|
|
pedptr->type = PED_ACTION_BACK;
|
|
|
|
pedptr->fpAgitatedState = NULL;
|
|
|
|
pedptr->fpRestState = fpPedPersonalityFunctions[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pedptr->type = PED_ACTION_GETOUTCAR;
|
|
|
|
pedptr->fpRestState = fpPedPersonalityFunctions[0];
|
|
|
|
pedptr->fpAgitatedState = PedGetOutCar;
|
|
|
|
}
|
|
|
|
|
|
|
|
pedptr->position.vx = v.vx;
|
|
|
|
pedptr->position.vz = v.vz;
|
|
|
|
|
|
|
|
if (pCar != NULL)
|
2021-05-04 15:40:08 +02:00
|
|
|
pedptr->position.vy = pCar->hd.where.t[1];
|
2020-12-09 09:33:57 +01:00
|
|
|
|
|
|
|
pedptr->position.vy = -130 - MapHeight(pos);
|
|
|
|
pedptr->dir.vz = 0;
|
|
|
|
pedptr->dir.vx = 0;
|
|
|
|
pedptr->dir.vy = dir;
|
|
|
|
pedptr->head_rot = 0;
|
|
|
|
|
|
|
|
pPlayerPed = pedptr;
|
|
|
|
lp->headTimer = 0;
|
|
|
|
pedptr->pedType = playerType;
|
|
|
|
SetupPedestrian(pedptr);
|
|
|
|
|
|
|
|
if (pCar == NULL)
|
|
|
|
{
|
|
|
|
lp->cameraView = 0;
|
|
|
|
lp->headPos = 0;
|
|
|
|
lp->headTarget = 0;
|
|
|
|
lp->headTimer = 0;
|
|
|
|
lp->playerType = 2;
|
|
|
|
lp->cameraAngle = dir;
|
|
|
|
lp->cameraCarId = -1;
|
|
|
|
lp->worldCentreCarId = -1;
|
|
|
|
|
|
|
|
lp->pos[0] = pedptr->position.vx;
|
|
|
|
lp->pos[1] = pedptr->position.vy;
|
|
|
|
lp->pos[2] = pedptr->position.vz;
|
|
|
|
|
|
|
|
lp->spoolXZ = pos;
|
|
|
|
lp->pPed = pedptr;
|
|
|
|
lp->onGrass = 0;
|
|
|
|
lp->dir = d;
|
|
|
|
|
|
|
|
pedptr->frame1 = 0;
|
|
|
|
pedptr->speed = 0;
|
|
|
|
|
|
|
|
if (playerType == OTHER_SPRITE)
|
|
|
|
{
|
|
|
|
if (gCurrentMissionNumber == 9)
|
|
|
|
{
|
|
|
|
pedptr->pallet = 68;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-03 11:11:28 +02:00
|
|
|
int rnd1 = Random2(0);
|
|
|
|
int rnd2 = Random2(0);
|
|
|
|
|
|
|
|
pedptr->pallet = rnd1 - rnd1 / 3 * 3 + (rnd2 - rnd2 / 3 * 3) * 16;
|
2020-12-09 09:33:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MakeTheCarShutUp(playerId);
|
|
|
|
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 2, lp->pos[0], lp->pos[1], lp->pos[2], 0, 0x1000);
|
|
|
|
SetupGetOutCar(pedptr, pCar, side);
|
|
|
|
|
|
|
|
//pedptr->padId = 0;
|
|
|
|
lp->pPed = pedptr;
|
|
|
|
|
|
|
|
SetConfusedCar(lp->playerCarId);
|
|
|
|
StopPadVibration(0);
|
|
|
|
StopPadVibration(1);
|
|
|
|
|
|
|
|
lp->onGrass = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pedptr->doing_turn = 0;
|
|
|
|
|
|
|
|
gGotInStolenCar = 0;
|
|
|
|
bKillTanner = 0;
|
|
|
|
bKilled = 0;
|
|
|
|
|
|
|
|
if (gCurrentMissionNumber == 23 && playerType != TANNER_MODEL)
|
|
|
|
{
|
|
|
|
pedptr->doing_turn = 16;
|
|
|
|
pedptr->dir.vy = (pedptr->dir.vy - (tannerTurnMax + 16) * tannerTurnStep) + 294;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [D] [T]
|
|
|
|
void DeActivatePlayerPedestrian(PEDESTRIAN* pPed)
|
|
|
|
{
|
|
|
|
CAR_DATA* cp;
|
|
|
|
int playerId;
|
|
|
|
int getIn;
|
|
|
|
int distToCarSq;
|
|
|
|
|
|
|
|
getIn = 0;
|
|
|
|
playerId = pPed->padId;
|
|
|
|
|
|
|
|
if (playerId < 0)
|
|
|
|
playerId = -playerId;
|
|
|
|
|
|
|
|
cp = FindClosestCar(player[playerId].pos[0], player[playerId].pos[1], player[playerId].pos[2], &distToCarSq);
|
|
|
|
|
|
|
|
if (!cp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cp->ap.model == 4)
|
|
|
|
getIn = FindPointOfCollision(cp, pPed);
|
|
|
|
else if (cp && TannerCanEnterCar(cp, distToCarSq))
|
|
|
|
getIn = 1;
|
|
|
|
|
|
|
|
if (getIn != 0)
|
|
|
|
{
|
|
|
|
carToGetIn = cp;
|
|
|
|
pPed->type = PED_ACTION_GETINCAR;
|
|
|
|
pPed->fpAgitatedState = PedGetInCar;
|
|
|
|
|
|
|
|
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 2, player[0].pos[0], player[0].pos[1], player[0].pos[2], 0, 0x1000);
|
|
|
|
SetupPedestrian(pPed);
|
|
|
|
SetupGetInCar(pPed);
|
|
|
|
}
|
|
|
|
}
|