2020-09-05 20:12:14 +02:00
# include "DRIVER2.H"
2020-03-27 21:47:29 +01:00
# include "PEDEST.H"
2020-05-15 10:12:13 +02:00
# include "PLAYERS.H"
# include "MISSION.H"
# include "OBJCOLL.H"
# include "COSMETIC.H"
# include "MAIN.H"
# include "DR2ROADS.H"
# include "MOTION_C.H"
# include "CONVERT.H"
# include "GAMESND.H"
# include "SOUND.H"
# include "PAD.H"
2020-05-15 11:18:42 +02:00
# include "CIV_AI.H"
2020-05-15 11:53:03 +02:00
# include "GLAUNCH.H"
# include "CUTSCENE.H"
2020-05-15 12:00:42 +02:00
# include "CAMERA.H"
2020-05-15 12:33:29 +02:00
# include "PAUSE.H"
# include "AI.H"
# include "CARS.H"
# include "FELONY.H"
# include "BOMBERMAN.H"
2020-05-17 10:21:57 +02:00
# include "BCOLLIDE.H"
2020-05-23 16:36:40 +02:00
# include "MAP.H"
2020-05-24 10:22:31 +02:00
# include "SYSTEM.H"
2020-06-06 12:29:36 +02:00
# include "HANDLING.H"
2020-05-24 10:22:31 +02:00
2020-05-24 16:12:10 +02:00
# include "../ASM/ASMTEST.H"
2020-03-27 21:47:29 +01:00
2020-05-24 16:12:10 +02:00
# include "STRINGS.H"
# include "INLINE_C.H"
2020-03-27 21:47:29 +01:00
2020-05-24 11:07:53 +02: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
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
VECTOR tannerLookAngle = { 0 , 0 , 0 , 0 } ;
2020-05-15 10:12:13 +02:00
int tannerTurnMax = 16 ;
int tannerTurnStep = 4 ;
2020-03-27 21:47:29 +01:00
long force [ 4 ] = { 0x9000 , 0 , 0 , 0 } ;
2020-09-04 20:58:59 +02:00
long point [ 4 ] = { 0 , 0 , 90 , 0 } ;
2020-03-27 21:47:29 +01:00
2020-04-28 20:00:25 +02:00
int bKillTanner = 0 ;
2020-05-15 10:12:13 +02:00
SEATED_PEDESTRIANS * seated_pedestrian ; // lump
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-05-15 11:06:27 +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-05-15 11:36:25 +02:00
unsigned long 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-03-27 21:47:29 +01:00
// decompiled code
// original method signature:
// void /*$ra*/ IHaveThePower()
// line 1137, offset 0x0006dd34
/* begin block 1 */
// Start line: 1139
// Start offset: 0x0006DD34
// Variables:
// struct _CAR_DATA *cp; // $t4
/* begin block 1.1 */
// Start line: 1152
// Start offset: 0x0006DDB8
/* end block 1.1 */
// End offset: 0x0006DF20
// End Line: 1170
/* end block 1 */
// End offset: 0x0006DF54
// End Line: 1182
/* begin block 2 */
// Start line: 2274
/* end block 2 */
// End Line: 2275
/* begin block 3 */
// Start line: 2275
/* end block 3 */
// End Line: 2276
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-05-15 13:16:18 +02:00
int bPower = 0 ;
int oldWeather = 0 ;
int powerCounter = 0 ;
// [D]
// Havana easter egg.
2020-03-27 21:47:29 +01:00
void IHaveThePower ( void )
{
2020-05-15 13:16:18 +02:00
_CAR_DATA * cp ;
if ( GameLevel ! = 1 )
2020-04-03 00:44:09 +02:00
return ;
2020-05-15 13:16:18 +02: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 )
{
2020-04-03 00:44:09 +02:00
bPower = 0 ;
gWeather = oldWeather ;
}
2020-05-15 13:16:18 +02:00
return ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 13:16:18 +02:00
if ( ( tannerPad & 0x20 ) ! = 0 )
{
if ( bPower = = 0 )
{
oldWeather = gWeather ;
2020-05-16 19:10:15 +02:00
bPower = 1 ;
gWeather = 1 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 13:16:18 +02:00
powerCounter + + ;
// make cars go crazy
if ( powerCounter < 20 )
{
cp = car_data ;
do {
if ( cp - > controlType ! = 0 )
{
cp - > hd . acc [ 0 ] + = force [ 0 ] ;
cp - > hd . acc [ 1 ] + = force [ 1 ] ;
cp - > hd . acc [ 2 ] + = force [ 2 ] ;
2020-09-11 11:30:58 +02:00
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 ] ) ;
2020-05-15 13:16:18 +02:00
}
cp + + ;
2020-06-06 16:39:09 +02:00
} while ( cp < & car_data [ 20 ] ) ;
2020-05-15 13:16:18 +02:00
}
if ( powerCounter > 48 )
powerCounter = 0 ;
2020-04-03 00:44:09 +02:00
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ ProcessTannerPad(struct PEDESTRIAN *pPed /*$s1*/, unsigned long pad /*$a1*/, char PadSteer /*$a2*/, char use_analogue /*$a3*/)
// line 1191, offset 0x0006df54
/* begin block 1 */
// Start line: 1192
// Start offset: 0x0006DF54
// Variables:
// struct VECTOR vec; // stack offset -88
// int mapheight; // $s2
// struct VECTOR normal; // stack offset -72
// struct VECTOR out; // stack offset -56
// struct _sdPlane *SurfacePtr; // stack offset -24
/* begin block 1.1 */
// Start line: 1224
// Start offset: 0x0006DFC8
// Variables:
// struct VECTOR tVec; // stack offset -40
// struct _sdPlane *plane; // $v0
// int mH; // $v1
// int sI; // $a0
/* end block 1.1 */
// End offset: 0x0006E104
// End Line: 1277
/* begin block 1.2 */
// Start line: 1359
// Start offset: 0x0006E390
/* end block 1.2 */
// End offset: 0x0006E3F0
// End Line: 1365
/* end block 1 */
// End offset: 0x0006E3F0
// End Line: 1367
/* begin block 2 */
// Start line: 2378
/* end block 2 */
// End Line: 2379
/* begin block 3 */
// Start line: 2388
/* end block 3 */
// End Line: 2389
/* begin block 4 */
// Start line: 2397
/* end block 4 */
// End Line: 2398
2020-04-03 00:44:09 +02:00
void ProcessTannerPad ( PEDESTRIAN * pPed , ulong pad , char PadSteer , char use_analogue )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
PED_ACTION_TYPE PVar1 ;
int iVar2 ;
int iVar3 ;
int iVar4 ;
2020-09-04 21:09:51 +02:00
_sdPlane * SurfacePtr ;
short surface ;
2020-04-03 00:44:09 +02:00
uint uVar8 ;
2020-05-15 13:04:48 +02:00
VECTOR vec ;
VECTOR normal ;
VECTOR out ;
VECTOR tVec ;
2020-09-04 21:09:51 +02:00
_sdPlane * plane ;
2020-04-03 00:44:09 +02:00
2020-09-04 21:09:51 +02:00
plane = NULL ;
2020-04-03 00:44:09 +02:00
tannerPad = pad ;
2020-05-15 13:04:48 +02:00
if ( use_analogue )
{
2020-04-03 00:44:09 +02:00
tannerPad = pad ;
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
if ( PadSteer ! = 0 )
tannerPad | = ( PadSteer < 0 ) ? 0x8000 : 0x2000 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 13:04:48 +02:00
2020-05-15 13:16:18 +02:00
IHaveThePower ( ) ; // process Havana easter egg near the entrance cemetery
2020-05-15 13:04:48 +02:00
vec . vx = pPed - > position . vx ;
vec . vy = - pPed - > position . vy ;
2020-09-04 21:09:51 +02:00
vec . vz = pPed - > position . vz ;
2020-06-22 19:50:29 +02:00
uVar8 = ( int ) pPed - > dir . vy - 0x800U & 0xfff ;
2020-09-04 21:09:51 +02:00
2020-05-15 13:04:48 +02:00
tVec . vx = vec . vx + ( rcossin_tbl [ uVar8 * 2 ] * 5 > > 9 ) ;
2020-09-04 21:09:51 +02:00
tVec . vy = vec . vy ;
2020-05-15 13:04:48 +02:00
tVec . vz = vec . vz + ( rcossin_tbl [ uVar8 * 2 + 1 ] * 5 > > 9 ) ;
2020-09-04 21:09:51 +02:00
bStopTanner = 0 ;
int mapheight [ 2 ] ;
mapheight [ 0 ] = - 130 - MapHeight ( & vec ) ;
mapheight [ 1 ] = - 130 - MapHeight ( & tVec ) ;
int dist = mapheight [ 1 ] - mapheight [ 0 ] ;
if ( dist < 0 )
dist = mapheight [ 0 ] - mapheight [ 1 ] ;
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
if ( dist < 1011 )
2020-05-15 13:04:48 +02:00
{
2020-09-04 21:09:51 +02:00
SurfacePtr = sdGetCell ( & tVec ) ;
surface = - 32 ;
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
if ( SurfacePtr ! = NULL )
{
surface = SurfacePtr - > surface ;
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
uVar8 = ( ( int ) ( ( uint ) ( ushort ) SurfacePtr - > b < < 0x10 ) > > 0x12 ) - 2048 & 0xfff ;
dist = uVar8 - 2048 ;
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
if ( dist < 0 )
dist = 2048 - uVar8 ;
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
if ( dist < 1101 )
{
switch ( surface )
{
case - 32 :
case 6 :
case 9 :
break ;
default :
dist = - 1 ;
break ;
}
}
}
2020-04-03 00:44:09 +02:00
}
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
if ( dist ! = - 1 )
bStopTanner = 1 ;
if ( ( pPed - > type ! = PED_ACTION_SIT ) & & ! bStopTanner )
pPed - > position . vy = mapheight [ 0 ] ;
2020-05-15 13:04:48 +02:00
2020-09-04 21:08:51 +02:00
if ( ( gInGameCutsceneActive = = 0 | | gCurrentMissionNumber ! = 23 ) | |
( ( gInGameCutsceneID ! = 0 | | ( CameraCnt ! = 0x1cb | | ( ( pPed - > pedType = = TANNER_MODEL ) | | ( ActiveCheats . cheat12 & & ( pPed - > pedType = = OTHER_MODEL ) ) ) ) ) ) )
2020-05-15 13:04:48 +02:00
{
if ( ( tannerPad & 0x10 ) ! = 0 )
{
2020-09-04 21:09:51 +02:00
if ( gTannerActionNeeded )
2020-05-15 13:04:48 +02:00
{
2020-09-04 21:09:51 +02:00
// 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 ;
}
2020-04-03 00:44:09 +02:00
}
2020-09-04 21:09:51 +02:00
else
2020-05-15 13:04:48 +02:00
{
2020-09-04 21:09:51 +02:00
// 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 ;
}
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
// 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 ) ;
}
}
2020-04-03 00:44:09 +02:00
}
2020-05-15 13:04:48 +02:00
if ( pPed ! = NULL )
{
2020-09-04 21:09:51 +02:00
if ( pPed - > fpAgitatedState ! = NULL )
2020-04-03 00:44:09 +02:00
( * pPed - > fpAgitatedState ) ( pPed ) ;
2020-09-04 21:09:51 +02:00
else
( * pPed - > fpRestState ) ( pPed ) ;
2020-05-15 13:04:48 +02:00
if ( player [ 0 ] . cameraView = = 2 & & pPed - > type ! = PED_ACTION_GETINCAR )
{
if ( oldCamView ! = player [ 0 ] . cameraView )
{
2020-04-03 00:44:09 +02:00
camAngle . vx = camera_angle . vx ;
camAngle . vz = camera_angle . vz ;
}
2020-05-15 13:04:48 +02:00
camAngle . vy = player [ 0 ] . headPos - player [ 0 ] . dir & 0xfff ;
2020-04-03 00:44:09 +02:00
TannerCameraHandler ( pPed ) ;
}
2020-05-15 13:04:48 +02:00
oldCamView = player [ 0 ] . cameraView ;
2020-04-03 00:44:09 +02:00
TannerCollision ( pPed ) ;
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
// sloped surfaces in chicago?
2020-05-15 13:04:48 +02:00
if ( GameLevel = = 0 )
{
2020-09-04 21:09:51 +02:00
FindSurfaceD2 ( ( VECTOR * ) player , & normal , & out , & plane ) ;
2020-05-15 13:04:48 +02:00
2020-09-04 21:09:51 +02:00
if ( plane - > surface ! = - 1 & & plane - > surface < 0x20 & & ( plane - > surface & 0x10U ) ! = 0 )
2020-05-15 13:04:48 +02:00
{
pPed - > position . vx + = ( normal . vx > > 6 ) ;
pPed - > position . vz + = ( normal . vz > > 6 ) ;
2020-04-03 00:44:09 +02:00
}
}
}
}
2020-05-15 13:04:48 +02:00
else
{
iVar2 = pPed - > padId ;
if ( iVar2 < 0 )
2020-04-03 00:44:09 +02:00
iVar2 = - iVar2 ;
2020-05-15 13:04:48 +02:00
player [ iVar2 ] . pPed = NULL ;
2020-05-20 17:33:53 +02:00
player [ iVar2 ] . playerType = 0 ;
2020-09-04 21:09:51 +02:00
2020-04-03 00:44:09 +02:00
DestroyPedestrian ( pPed ) ;
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ InitTanner()
// line 1375, offset 0x0006e408
/* begin block 1 */
// Start line: 1377
// Start offset: 0x0006E408
/* end block 1 */
// End offset: 0x0006E5C4
// End Line: 1433
/* begin block 2 */
// Start line: 2819
/* end block 2 */
// End Line: 2820
/* begin block 3 */
// Start line: 2820
/* end block 3 */
// End Line: 2821
/* begin block 4 */
// Start line: 2823
/* end block 4 */
// End Line: 2824
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-05-23 16:36:40 +02:00
// [D]
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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetTannerPosition(struct VECTOR *pVec /*$a0*/)
// line 1440, offset 0x00072478
/* begin block 1 */
// Start line: 1441
// Start offset: 0x00072478
// Variables:
// struct PEDESTRIAN *pPed; // $a1
/* end block 1 */
// End offset: 0x00072500
// End Line: 1459
/* begin block 2 */
// Start line: 11519
/* end block 2 */
// End Line: 11520
/* begin block 3 */
// Start line: 2880
/* end block 3 */
// End Line: 2881
/* begin block 4 */
// Start line: 11522
/* end block 4 */
// End Line: 11523
2020-05-15 10:12:13 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetTannerPosition ( VECTOR * pVec )
{
2020-05-15 10:12:13 +02:00
PEDESTRIAN * pPed ;
pPed = pUsedPeds ;
while ( pPed )
{
2020-09-04 21:08:51 +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 ;
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
}
// decompiled code
// original method signature:
// void /*$ra*/ InitPedestrians()
// line 1466, offset 0x0006e5c4
/* begin block 1 */
// Start line: 1468
// Start offset: 0x0006E5C4
// Variables:
// int loop; // $a1
// struct SEATED_PEDESTRIANS *seatedptr; // $s2
/* end block 1 */
// End offset: 0x0006E6C4
// End Line: 1513
/* begin block 2 */
// Start line: 2973
/* end block 2 */
// End Line: 2974
/* begin block 3 */
// Start line: 3007
/* end block 3 */
// End Line: 3008
/* begin block 4 */
// Start line: 3008
/* end block 4 */
// End Line: 3009
/* begin block 5 */
// Start line: 3009
/* end block 5 */
// End Line: 3010
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-05-15 10:12:13 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void InitPedestrians ( void )
{
2020-04-03 00:44:09 +02:00
short sVar1 ;
2020-09-04 20:58:59 +02:00
2020-05-15 10:12:13 +02:00
SEATED_PEDESTRIANS * seatedptr ;
2020-04-03 00:44:09 +02:00
2020-05-15 10:12:13 +02:00
memset ( pedestrians , 0 , sizeof ( pedestrians ) ) ;
2020-04-03 00:44:09 +02:00
DestroyPedestrians ( ) ;
2020-05-15 10:12:13 +02:00
2020-09-04 20:58:59 +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-09-04 20:58:59 +02:00
for ( int loop = 1 ; loop < MAX_PEDESTRIANS ; loop + + )
{
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 ;
if ( seatedptr ! = NULL )
{
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-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ DestroyPedestrians()
// line 1521, offset 0x00071f54
/* begin block 1 */
// Start line: 1523
// Start offset: 0x00071F54
/* end block 1 */
// End offset: 0x00071FB4
// End Line: 1534
/* begin block 2 */
// Start line: 3042
/* end block 2 */
// End Line: 3043
/* begin block 3 */
// Start line: 8489
/* end block 3 */
// End Line: 8490
/* begin block 4 */
// Start line: 8491
/* end block 4 */
// End Line: 8492
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-05-24 16:12:10 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void DestroyPedestrians ( void )
{
2020-05-15 10:12:13 +02:00
while ( pUsedPeds )
{
2020-09-04 21:08:51 +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-04-03 00:44:09 +02:00
num_pedestrians = 0 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ DestroyCivPedestrians()
// line 1541, offset 0x00072fd0
/* begin block 1 */
// Start line: 1543
// Start offset: 0x00072FD0
// Variables:
// struct PEDESTRIAN *pPed; // $v1
// struct PEDESTRIAN *pHPed; // $s0
/* end block 1 */
// End offset: 0x00073038
// End Line: 1559
/* begin block 2 */
// Start line: 3082
/* end block 2 */
// End Line: 3083
/* begin block 3 */
// Start line: 19292
/* end block 3 */
// End Line: 19293
/* begin block 4 */
// Start line: 19296
/* end block 4 */
// End Line: 19297
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-05-24 16:12:10 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void DestroyCivPedestrians ( void )
{
2020-05-24 16:12:10 +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
}
// decompiled code
// original method signature:
// void /*$ra*/ DestroyPedestrian(struct PEDESTRIAN *pPed /*$a1*/)
// line 1567, offset 0x00071fb4
/* begin block 1 */
// Start line: 1568
// Start offset: 0x00071FB4
/* begin block 1.1 */
// Start line: 1605
// Start offset: 0x00072064
// Variables:
// struct SEATED_PEDESTRIANS *seatedptr; // $a0
/* end block 1.1 */
// End offset: 0x00072090
// End Line: 1608
/* end block 1 */
// End offset: 0x000720AC
// End Line: 1616
/* begin block 2 */
// Start line: 8546
/* end block 2 */
// End Line: 8547
/* begin block 3 */
// Start line: 8580
/* end block 3 */
// End Line: 8581
2020-05-15 10:12:13 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void DestroyPedestrian ( PEDESTRIAN * pPed )
{
2020-05-15 10:12:13 +02:00
if ( ( pPed - > flags & 8U ) ! = 0 )
numCopPeds - - ;
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
if ( pUsedPeds ) // [A] is this valid? Or it was by Reflections?
pUsedPeds - > pPrev = NULL ;
2020-04-03 00:44:09 +02:00
pPed - > pNext = pFreePeds ;
2020-06-21 10:49:50 +02:00
if ( pFreePeds )
pFreePeds - > pPrev = pPed ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
else
{
2020-08-30 16:50:31 +02:00
if ( pPed - > pPrev )
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-06-21 10:49:50 +02:00
if ( pFreePeds )
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
}
// decompiled code
// original method signature:
// int /*$ra*/ ActivatePlayerPedestrian(struct _CAR_DATA *pCar /*$s6*/, char *padId /*stack 4*/, int direction /*$a1*/, long (*position)[4] /*$a3*/, int playerType /*stack 16*/)
// line 1623, offset 0x0006e6c4
/* begin block 1 */
// Start line: 1624
// Start offset: 0x0006E6C4
// Variables:
// struct PEDESTRIAN *pPed; // $s1
// struct PEDESTRIAN *pSPed; // $a0
// struct VECTOR v; // stack offset -72
// int nx; // $s4
// int nz; // $s2
// long w; // $s0
// long x; // $s5
// long y; // stack offset -52
// long z; // $s1
// long d; // stack offset -48
// int side; // $fp
// int id; // $s3
/* begin block 1.1 */
// Start line: 1688
// Start offset: 0x0006E7D4
/* begin block 1.1.1 */
// Start line: 1763
// Start offset: 0x0006EA48
/* end block 1.1.1 */
// End offset: 0x0006EA48
// End Line: 1763
/* begin block 1.1.2 */
// Start line: 1807
// Start offset: 0x0006EB48
/* end block 1.1.2 */
// End offset: 0x0006EB48
// End Line: 1807
/* end block 1.1 */
// End offset: 0x0006EB48
// End Line: 1807
/* end block 1 */
// End offset: 0x0006EC88
// End Line: 1835
/* begin block 2 */
// Start line: 3244
/* end block 2 */
// End Line: 3245
/* begin block 3 */
// Start line: 3355
/* end block 3 */
// End Line: 3356
/* begin block 4 */
// Start line: 3365
/* end block 4 */
// End Line: 3366
/* WARNING: Type propagation algorithm not settling */
2020-05-15 10:12:13 +02:00
// [D]
2020-09-13 08:39:01 +02:00
int ActivatePlayerPedestrian ( _CAR_DATA * pCar , char * padId , int direction , long ( * position ) [ 4 ] , PED_MODEL_TYPES playerType )
2020-03-27 21:47:29 +01:00
{
2020-05-15 10:12:13 +02:00
int iVar3 ;
2020-04-03 00:44:09 +02:00
int side ;
2020-05-15 10:12:13 +02:00
int dir ;
2020-04-03 00:44:09 +02:00
PEDESTRIAN * pedptr ;
long lVar5 ;
2020-05-15 10:12:13 +02:00
int playerId ;
2020-04-03 00:44:09 +02:00
long lVar7 ;
VECTOR * pos ;
2020-05-15 10:12:13 +02:00
VECTOR v ;
long y ;
long d ;
2020-06-06 12:29:36 +02:00
_PLAYER * lp ;
2020-04-03 00:44:09 +02:00
2020-06-22 19:50:29 +02:00
if ( numTannerPeds > 7 )
return 0 ;
2020-05-15 10:12:13 +02:00
if ( padId = = NULL )
{
2020-06-06 12:29:36 +02:00
playerId = GetPlayerId ( pCar ) ;
lp = & player [ playerId ] ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
else
{
iVar3 = ( int ) * padId ;
playerId = - iVar3 ;
if ( iVar3 > - 1 )
playerId = iVar3 ;
2020-04-03 00:44:09 +02:00
pedptr = pUsedPeds ;
2020-05-15 10:12:13 +02:00
if ( pUsedPeds ! = NULL )
{
2020-04-03 00:44:09 +02:00
do {
2020-05-15 10:12:13 +02:00
if ( pedptr - > padId = = iVar3 )
{
player [ playerId ] . pPed = pedptr ;
2020-04-03 00:44:09 +02:00
return 0 ;
}
2020-06-06 12:29:36 +02:00
2020-04-03 00:44:09 +02:00
pedptr = pedptr - > pNext ;
2020-05-15 10:12:13 +02:00
} while ( pedptr ! = NULL ) ;
2020-04-03 00:44:09 +02:00
}
2020-06-06 12:29:36 +02:00
lp = & player [ playerId ] ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
2020-05-24 11:07:53 +02:00
int x , z ;
2020-05-15 10:12:13 +02:00
if ( pCar = = NULL )
{
2020-05-24 11:07:53 +02:00
x = ( * position ) [ 0 ] ;
z = ( * position ) [ 2 ] ;
2020-05-15 10:12:13 +02:00
iVar3 = 1 ;
d = direction ;
y = 0 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
else
{
2020-05-24 11:07:53 +02:00
x = pCar - > hd . where . t [ 0 ] ;
z = pCar - > hd . where . t [ 2 ] ;
2020-05-15 10:12:13 +02:00
y = pCar - > hd . where . t [ 1 ] ;
d = pCar - > hd . direction ;
iVar3 = car_cosmetics [ pCar - > ap . model ] . colBox . vx ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
iVar3 + = 90 ;
dir = d - 0x800 ;
v . vy = y ;
2020-05-24 11:07:53 +02:00
v . vx = x - FIXED ( iVar3 * rcossin_tbl [ ( d & 0xfffU ) * 2 + 1 ] ) ;
v . vz = z + FIXED ( iVar3 * rcossin_tbl [ ( d & 0xfffU ) * 2 ] ) ;
2020-05-15 10:12:13 +02:00
side = 0 ;
if ( pCar ! = NULL )
{
if ( QuickBuildingCollisionCheck ( & v , dir , 10 , 10 , 10 ) ! = 0 | | TannerCarCollisionCheck ( & v , d , 1 ) ! = 0 )
{
2020-04-03 00:44:09 +02:00
side = 1 ;
2020-05-15 10:12:13 +02:00
v . vy = y ;
2020-05-24 11:07:53 +02:00
v . vx = x - FIXED ( - iVar3 * rcossin_tbl [ ( d & 0xfffU ) * 2 + 1 ] ) ;
v . vz = z + FIXED ( - iVar3 * rcossin_tbl [ ( d & 0xfffU ) * 2 ] ) ;
2020-05-15 10:12:13 +02:00
iVar3 = QuickBuildingCollisionCheck ( & v , dir , 10 , 10 , 10 ) ;
2020-05-24 12:34:22 +02:00
2020-05-15 10:12:13 +02:00
if ( iVar3 ! = 0 )
2020-04-03 00:44:09 +02:00
return 0 ;
2020-05-15 10:12:13 +02:00
iVar3 = TannerCarCollisionCheck ( & v , d , 1 ) ;
if ( iVar3 ! = 0 )
2020-04-03 00:44:09 +02:00
return 0 ;
}
}
2020-05-15 10:12:13 +02:00
2020-04-03 00:44:09 +02:00
pedptr = CreatePedestrian ( ) ;
2020-05-15 10:12:13 +02:00
numTannerPeds + + ;
2020-06-22 20:10:11 +02:00
pedptr - > interest = 0 ; // idle timer
pedptr - > flags & = ~ 4 ; // reverse animation
2020-06-22 19:50:29 +02:00
2020-05-15 10:12:13 +02:00
if ( padId = = NULL )
2020-06-06 12:29:36 +02:00
pedptr - > padId = playerId ;
2020-05-15 10:12:13 +02:00
else
2020-04-03 00:44:09 +02:00
pedptr - > padId = * padId ;
2020-05-15 10:12:13 +02:00
if ( pedptr = = NULL )
{
pos = NULL ;
while ( FrameCnt ! = 0x78654321 )
{
2020-04-03 00:44:09 +02:00
trap ( 0x400 ) ;
}
}
2020-05-15 10:12:13 +02:00
else
pos = ( VECTOR * ) & pedptr - > position ;
if ( pCar = = NULL )
{
2020-04-03 00:44:09 +02:00
pedptr - > type = PED_ACTION_BACK ;
2020-05-15 10:12:13 +02:00
pedptr - > fpAgitatedState = NULL ;
pedptr - > fpRestState = fpPedPersonalityFunctions [ 0 ] ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
else
{
2020-04-03 00:44:09 +02:00
pedptr - > type = PED_ACTION_GETOUTCAR ;
2020-05-15 10:12:13 +02:00
pedptr - > fpRestState = fpPedPersonalityFunctions [ 0 ] ;
pedptr - > fpAgitatedState = PedGetOutCar ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
pedptr - > position . vx = v . vx ;
pedptr - > position . vz = v . vz ;
if ( pCar ! = NULL )
pedptr - > position . vy = ( pCar - > hd ) . where . t [ 1 ] ;
pedptr - > position . vy = - 130 - MapHeight ( pos ) ;
pedptr - > dir . vz = 0 ;
pedptr - > dir . vx = 0 ;
pedptr - > dir . vy = dir ;
2020-04-03 00:44:09 +02:00
pedptr - > head_rot = 0 ;
2020-05-15 10:12:13 +02:00
2020-04-03 00:44:09 +02:00
pPlayerPed = pedptr ;
2020-06-06 12:29:36 +02:00
lp - > headTimer = 0 ;
2020-09-13 08:39:01 +02:00
pedptr - > pedType = playerType ;
2020-04-03 00:44:09 +02:00
SetupPedestrian ( pedptr ) ;
2020-05-15 10:12:13 +02:00
if ( pCar = = NULL )
{
2020-06-06 12:29:36 +02:00
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 ;
2020-05-15 10:12:13 +02:00
pedptr - > frame1 = 0 ;
pedptr - > speed = 0 ;
2020-09-04 21:09:51 +02:00
if ( playerType = = OTHER_SPRITE )
2020-05-15 10:12:13 +02:00
{
if ( gCurrentMissionNumber = = 9 )
{
pedptr - > pallet = 68 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
else
{
2020-04-03 00:44:09 +02:00
lVar5 = Random2 ( 0 ) ;
lVar7 = Random2 ( 0 ) ;
2020-05-15 10:12:13 +02:00
pedptr - > pallet = lVar5 - ( lVar5 / 3 ) * 3 + ( lVar7 - ( lVar7 / 3 ) * 3 ) * 16 ;
2020-04-03 00:44:09 +02:00
}
}
}
2020-05-15 10:12:13 +02:00
else
{
2020-06-06 12:29:36 +02:00
MakeTheCarShutUp ( playerId ) ;
Start3DSoundVolPitch ( - 1 , 6 , 2 , lp - > pos [ 0 ] , lp - > pos [ 1 ] , lp - > pos [ 2 ] , 0 , 0x1000 ) ;
2020-04-03 00:44:09 +02:00
SetupGetOutCar ( pedptr , pCar , side ) ;
2020-05-15 10:12:13 +02:00
2020-06-06 12:29:36 +02:00
//pedptr->padId = 0;
lp - > pPed = pedptr ;
2020-05-15 10:12:13 +02:00
2020-06-06 12:29:36 +02:00
SetConfusedCar ( lp - > playerCarId ) ;
2020-04-03 00:44:09 +02:00
StopPadVibration ( 0 ) ;
StopPadVibration ( 1 ) ;
2020-05-15 10:12:13 +02:00
2020-06-06 12:29:36 +02:00
lp - > onGrass = 0 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
2020-06-22 19:50:29 +02:00
pedptr - > doing_turn = 0 ;
2020-04-03 00:44:09 +02:00
gGotInStolenCar = 0 ;
bKillTanner = 0 ;
bKilled = 0 ;
2020-05-15 10:12:13 +02:00
2020-09-04 21:09:51 +02:00
if ( gCurrentMissionNumber = = 23 & & playerType ! = TANNER_MODEL )
2020-05-15 10:12:13 +02:00
{
2020-06-22 19:50:29 +02:00
pedptr - > doing_turn = 16 ;
2020-05-15 10:12:13 +02:00
pedptr - > dir . vy = ( pedptr - > dir . vy - ( tannerTurnMax + 16 ) * tannerTurnStep ) + 294 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 10:12:13 +02:00
return 1 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// struct PEDESTRIAN * /*$ra*/ CreatePedestrian()
// line 1842, offset 0x000720ac
/* begin block 1 */
// Start line: 1844
// Start offset: 0x000720AC
/* end block 1 */
// End offset: 0x00072114
// End Line: 1869
/* begin block 2 */
// Start line: 8911
/* end block 2 */
// End Line: 8912
/* begin block 3 */
// Start line: 9138
/* end block 3 */
// End Line: 9139
/* begin block 4 */
// Start line: 9139
/* end block 4 */
// End Line: 9140
/* begin block 5 */
// Start line: 9141
/* end block 5 */
// End Line: 9142
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-05-15 10:12:13 +02:00
// [D]
2020-03-27 21:47:29 +01:00
PEDESTRIAN * CreatePedestrian ( void )
{
2020-05-15 10:12:13 +02:00
PEDESTRIAN * pNewPed ;
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
}
// decompiled code
// original method signature:
// void /*$ra*/ PlaceRoadBlockCops()
// line 1877, offset 0x0006ec88
/* begin block 1 */
// Start line: 1879
// Start offset: 0x0006EC88
// Variables:
// struct _CAR_DATA *pCar; // $a0
// struct _CAR_DATA (*pCopCars[16]); // stack offset -152
// int numCops; // $fp
/* begin block 1.1 */
// Start line: 1896
// Start offset: 0x0006ED1C
// Variables:
// int x; // $s2
// int z; // $s0
// int w; // $s0
// int i; // $s7
// int s1; // $s1
// int s2; // $a3
// struct VECTOR vert; // stack offset -88
// long disp[4]; // stack offset -72
// long dir[4]; // stack offset -56
// int alpha; // $s1
/* end block 1.1 */
// End offset: 0x0006EFDC
// End Line: 1966
/* end block 1 */
// End offset: 0x0006EFDC
// End Line: 1968
/* begin block 2 */
// Start line: 4102
/* end block 2 */
// End Line: 4103
/* begin block 3 */
// Start line: 4145
/* end block 3 */
// End Line: 4146
/* begin block 4 */
// Start line: 4146
/* end block 4 */
// End Line: 4147
/* begin block 5 */
// Start line: 4150
/* end block 5 */
// End Line: 4151
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-07-05 18:56:30 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void PlaceRoadBlockCops ( void )
{
2020-04-03 00:44:09 +02:00
short sVar1 ;
int iVar2 ;
2020-07-05 18:56:30 +02:00
int iVar3 ;
uint uVar4 ;
_CAR_DATA * * pp_Var5 ;
_CAR_DATA * p_Var6 ;
int a ;
2020-04-03 00:44:09 +02:00
int iVar8 ;
2020-07-05 18:56:30 +02:00
_CAR_DATA * pCar ;
2020-04-03 00:44:09 +02:00
int iVar9 ;
2020-07-05 18:56:30 +02:00
int iVar10 ;
_CAR_DATA * pCopCars [ 16 ] ;
VECTOR vert ;
long disp [ 4 ] ;
long dir [ 4 ] ;
iVar10 = 0 ;
if ( numCopPeds < 8 )
{
p_Var6 = car_data ;
pp_Var5 = pCopCars ;
2020-04-03 00:44:09 +02:00
do {
2020-07-05 18:56:30 +02:00
if ( ( p_Var6 - > controlFlags & 2 ) ! = 0 )
{
* pp_Var5 + + = p_Var6 ;
iVar10 + + ;
2020-04-03 00:44:09 +02:00
}
2020-07-05 18:56:30 +02:00
p_Var6 + + ;
2020-09-27 11:03:11 +02:00
} while ( p_Var6 < car_data + MAX_CARS ) ;
2020-07-05 18:56:30 +02:00
if ( iVar10 ! = 0 & & 0 < iVar10 )
{
iVar9 = 0 ;
a = 0 ;
2020-04-03 00:44:09 +02:00
do {
2020-07-05 18:56:30 +02:00
pCar = pCopCars [ iVar9 ] ;
a = ( pCar - > hd ) . direction ;
sVar1 = car_cosmetics [ pCar - > ap . model ] . colBox . vx ;
iVar2 = rsin ( a ) ;
iVar3 = rcos ( a ) ;
disp [ 0 ] = pCar - > hd . where . t [ 0 ] - player [ 0 ] . pos [ 0 ] ;
disp [ 1 ] = 0 ;
disp [ 2 ] = pCar - > hd . where . t [ 2 ] - player [ 0 ] . pos [ 2 ] ;
a = car_cosmetics [ pCar - > ap . model ] . colBox . vx + 400 ;
iVar8 = car_cosmetics [ pCar - > ap . model ] . colBox . vz - 120 ;
if ( FIXED ( iVar3 * 0x1000 ) * disp [ 0 ] - FIXED ( iVar2 * 0x1000 ) * disp [ 2 ] + 0x800 < 0 )
a = - a ;
uVar4 = pCar - > hd . direction + 0x800U & 0xfff ;
iVar3 = ( int ) rcossin_tbl [ uVar4 * 2 + 1 ] ;
iVar2 = ( int ) rcossin_tbl [ uVar4 * 2 ] ;
disp [ 0 ] = pCar - > hd . where . t [ 0 ] - ( FIXED ( a * iVar3 ) - FIXED ( iVar8 * iVar2 ) ) ;
disp [ 1 ] = - pCar - > hd . where . t [ 1 ] ;
disp [ 2 ] = pCar - > hd . where . t [ 2 ] + FIXED ( a * iVar2 ) + FIXED ( iVar8 * iVar3 ) ;
if ( CreatePedAtLocation ( ( long ( * ) [ 4 ] ) disp , 12 ) ! = 0 )
numCopPeds + + ;
iVar3 = ( int ) rcossin_tbl [ uVar4 * 2 + 1 ] ;
iVar2 = ( int ) rcossin_tbl [ uVar4 * 2 ] ;
disp [ 0 ] = pCar - > hd . where . t [ 0 ] - ( FIXED ( a * iVar3 ) - FIXED ( - iVar8 * iVar2 ) ) ;
disp [ 1 ] = - pCar - > hd . where . t [ 1 ] ;
disp [ 2 ] = pCar - > hd . where . t [ 2 ] + FIXED ( a * iVar2 ) + FIXED ( - iVar8 * iVar3 ) ;
if ( CreatePedAtLocation ( ( long ( * ) [ 4 ] ) disp , 13 ) ! = 0 )
2020-04-03 00:44:09 +02:00
numCopPeds = numCopPeds + 1 ;
2020-07-05 18:56:30 +02:00
iVar9 + + ;
a = iVar9 * 4 ;
} while ( iVar9 < iVar10 ) ;
2020-04-03 00:44:09 +02:00
}
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// int /*$ra*/ CreatePedAtLocation(long (*pPos)[4] /*$s2*/, int pedType /*$s1*/)
// line 1975, offset 0x0006f00c
/* begin block 1 */
// Start line: 1976
// Start offset: 0x0006F00C
// Variables:
// struct PEDESTRIAN *pPed; // $s0
/* end block 1 */
// End offset: 0x0006F16C
// End Line: 2045
/* begin block 2 */
// Start line: 4495
/* end block 2 */
// End Line: 4496
2020-05-24 10:21:19 +02:00
// [D]
2020-04-03 00:44:09 +02:00
int CreatePedAtLocation ( long ( * pPos ) [ 4 ] , int pedType )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
PEDESTRIAN * pPed ;
2020-05-24 10:21:19 +02:00
if ( pedType - 0xcU < 2 )
{
if ( numCopPeds > 7 )
2020-04-03 00:44:09 +02:00
return 0 ;
}
2020-05-24 10:21:19 +02:00
else if ( num_pedestrians > 15 )
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
pedFunc pedRestState = fpPedPersonalityFunctions [ 12 ] ;
if ( pedType = = 8 )
{
2020-04-03 00:44:09 +02:00
pPed - > flags = 0 ;
2020-05-24 10:21:19 +02:00
pedRestState = fpPedPersonalityFunctions [ 7 ] ;
2020-04-03 00:44:09 +02:00
}
2020-05-24 10:21:19 +02:00
else
{
if ( pedType < 8 | | pedType > 13 | | pedType < 12 )
goto LAB_0006f100 ;
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 - > fpRestState = pedRestState ;
2020-03-27 21:47:29 +01:00
LAB_0006f100 :
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
if ( pPed - > type = = PED_ACTION_COPSTAND )
{
pPed - > position . vy = - 98 - MapHeight ( ( VECTOR * ) & pPed - > position ) ;
2020-04-03 00:44:09 +02:00
}
2020-05-24 10:21:19 +02:00
else
{
if ( pPed - > type ! = PED_ACTION_COPCROUCH )
2020-04-03 00:44:09 +02:00
return 1 ;
2020-05-24 10:21:19 +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
}
// decompiled code
// original method signature:
// void /*$ra*/ DrawAllPedestrians()
// line 2052, offset 0x00072290
/* begin block 1 */
// Start line: 2054
// Start offset: 0x00072290
// Variables:
// struct PEDESTRIAN *pPed; // $s0
// int pedType; // $s2
// struct MATRIX mStore; // stack offset -56
/* begin block 1.1 */
// Start line: 2071
// Start offset: 0x0007231C
/* begin block 1.1.1 */
// Start line: 2078
// Start offset: 0x0007234C
/* end block 1.1.1 */
// End offset: 0x0007234C
// End Line: 2078
/* end block 1.1 */
// End offset: 0x00072364
// End Line: 2085
/* begin block 1.2 */
// Start line: 2101
// Start offset: 0x000723D4
/* end block 1.2 */
// End offset: 0x00072400
// End Line: 2106
/* end block 1 */
// End offset: 0x00072430
// End Line: 2137
/* begin block 2 */
// Start line: 12025
/* end block 2 */
// End Line: 12026
/* begin block 3 */
// Start line: 4104
/* end block 3 */
// End Line: 4105
/* begin block 4 */
// Start line: 12026
/* end block 4 */
// End Line: 12027
/* begin block 5 */
// Start line: 12031
/* end block 5 */
// End Line: 12032
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-09-04 21:09:51 +02:00
int PedVisible ( PEDESTRIAN * pPed , int bounding_sphere )
{
VECTOR * pos = ( VECTOR * ) & pPed - > position ;
if ( PositionVisible ( pos ) & & FrustrumCheck ( pos , bounding_sphere ) ! = - 1 )
return 1 ;
return 0 ;
}
int DrawPedestrian ( PEDESTRIAN * pPed )
{
switch ( pPed - > type )
{
case PED_ACTION_CIVWALK :
case PED_ACTION_CIVRUN :
case PED_ACTION_JUMP :
case PED_ACTION_CIVSIT :
case PED_ACTION_COPSTAND :
case PED_ACTION_COPCROUCH :
DrawCiv ( pPed ) ;
return 1 ;
}
return DrawCharacter ( pPed ) ;
}
2020-05-24 16:12:10 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void DrawAllPedestrians ( void )
{
2020-04-03 00:44:09 +02:00
PEDESTRIAN * pPed ;
2020-05-24 16:12:10 +02:00
MATRIX mStore ;
gte_ReadRotMatrix ( & mStore ) ;
2020-04-03 00:44:09 +02:00
pPed = pUsedPeds ;
2020-05-24 16:12:10 +02:00
while ( pPed ! = NULL )
{
2020-09-04 21:09:51 +02:00
if ( pPed - > pedType > OTHER_MODEL & & PedVisible ( pPed , 60 ) )
DrawPedestrian ( 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
gte_SetRotMatrix ( & mStore ) ;
2020-04-03 00:44:09 +02:00
pPed = pUsedPeds ;
2020-05-24 16:12:10 +02:00
while ( pPed ! = NULL )
{
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-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// int /*$ra*/ TannerActionHappening()
// line 2145, offset 0x00072430
/* begin block 1 */
// Start line: 2147
// Start offset: 0x00072430
// Variables:
// struct PEDESTRIAN *pPed; // $a0
/* end block 1 */
// End offset: 0x00072478
// End Line: 2158
/* begin block 2 */
// Start line: 12203
/* end block 2 */
// End Line: 12204
/* begin block 3 */
// Start line: 12212
/* end block 3 */
// End Line: 12213
/* begin block 4 */
// Start line: 12213
/* end block 4 */
// End Line: 12214
/* begin block 5 */
// Start line: 12215
/* end block 5 */
// End Line: 12216
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-05-15 11:06:27 +02:00
// [D]
2020-03-27 21:47:29 +01:00
int TannerActionHappening ( void )
{
2020-05-15 11:06:27 +02:00
PEDESTRIAN * pPed = player [ 0 ] . pPed ;
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
}
// decompiled code
// original method signature:
// void /*$ra*/ ControlPedestrians()
// line 2168, offset 0x0006f16c
/* begin block 1 */
// Start line: 2170
// Start offset: 0x0006F16C
// Variables:
// struct PEDESTRIAN *pPed; // $s0
// struct PEDESTRIAN *pPedNext; // $s2
// struct _CAR_DATA *pCar; // $v0
/* begin block 1.1 */
// Start line: 2225
// Start offset: 0x0006F26C
/* end block 1.1 */
// End offset: 0x0006F2B0
// End Line: 2233
/* end block 1 */
// End offset: 0x0006F2DC
// End Line: 2241
/* begin block 2 */
// Start line: 4773
/* end block 2 */
// End Line: 4774
/* begin block 3 */
// Start line: 4897
/* end block 3 */
// End Line: 4898
/* begin block 4 */
// Start line: 4898
/* end block 4 */
// End Line: 4899
/* begin block 5 */
// Start line: 4902
/* end block 5 */
// End Line: 4903
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-05-15 11:06:27 +02:00
int bAvoidTanner = 0 ;
int bAvoidBomb = - 1 ;
// [D]
2020-03-27 21:47:29 +01:00
void ControlPedestrians ( void )
{
2020-05-15 11:06:27 +02:00
_CAR_DATA * pCar ;
2020-04-03 00:44:09 +02:00
PEDESTRIAN * pPed ;
2020-05-15 11:06:27 +02:00
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 ) ;
else
( * pPed - > fpAgitatedState ) ( pPed ) ;
if ( pPed - > type ! = PED_ACTION_GETINCAR )
{
pCar = CheckForCar ( pPed ) ;
if ( pCar )
SetupCivJump ( pPed , pCar ) ;
}
if ( bAvoidTanner = = 0 )
{
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-05-15 11:06:27 +02:00
else
{
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-05-15 11:06:27 +02:00
else
{
pPed = pPed - > pNext ;
2020-04-03 00:44:09 +02:00
}
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupDoNowt(struct PEDESTRIAN *pPed /*$s0*/)
// line 2256, offset 0x00073038
/* begin block 1 */
// Start line: 20024
/* end block 1 */
// End Line: 20025
/* begin block 2 */
// Start line: 20722
/* end block 2 */
// End Line: 20723
2020-05-15 11:06:27 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupDoNowt ( PEDESTRIAN * pPed )
{
2020-05-15 11:06:27 +02:00
pPed - > speed = 0 ;
pPed - > dir . vz = 0 ;
pPed - > doing_turn = 0 ;
2020-04-03 00:44:09 +02:00
pPed - > type = PED_ACTION_BACK ;
2020-05-15 11:06:27 +02:00
2020-04-03 00:44:09 +02:00
SetupPedMotionData ( pPed ) ;
2020-05-15 11:06:27 +02:00
pPed - > flags | = 0x10 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupWalker(struct PEDESTRIAN *pPed /*$s0*/)
// line 2275, offset 0x0007307c
/* begin block 1 */
// Start line: 20767
/* end block 1 */
// End Line: 20768
2020-05-15 11:18:42 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupWalker ( PEDESTRIAN * pPed )
{
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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupRunner(struct PEDESTRIAN *pPed /*$s0*/)
// line 2291, offset 0x000730b8
/* begin block 1 */
// Start line: 20802
/* end block 1 */
// End Line: 20803
2020-05-15 11:18:42 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupRunner ( PEDESTRIAN * pPed )
{
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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupBack(struct PEDESTRIAN *pPed /*$s0*/)
// line 2302, offset 0x000730fc
/* begin block 1 */
// Start line: 20826
/* end block 1 */
// End Line: 20827
2020-05-15 11:18:42 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupBack ( PEDESTRIAN * pPed )
{
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
}
// decompiled code
// original method signature:
// void /*$ra*/ CivGetIn(struct PEDESTRIAN *pPed /*$s2*/)
// line 2325, offset 0x00072dfc
/* begin block 1 */
// Start line: 2326
// Start offset: 0x00072DFC
// Variables:
// struct DRIVER2_STRAIGHT *str; // $s1
// struct DRIVER2_CURVE *crv; // $s0
/* begin block 1.1 */
// Start line: 2326
// Start offset: 0x00072DFC
/* end block 1.1 */
// End offset: 0x00072EE4
// End Line: 2345
/* end block 1 */
// End offset: 0x00072EE4
// End Line: 2346
/* begin block 2 */
// Start line: 18692
/* end block 2 */
// End Line: 18693
/* begin block 3 */
// Start line: 4650
/* end block 3 */
// End Line: 4651
/* begin block 4 */
// Start line: 18693
/* end block 4 */
// End Line: 18694
2020-05-15 11:53:03 +02:00
_CAR_DATA * pCivCarToGetIn = NULL ;
2020-05-15 11:18:42 +02:00
// [D]
void CivGetIn ( PEDESTRIAN * pPed ) // [A] UNUSED
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
uint uVar2 ;
DRIVER2_CURVE * curve ;
DRIVER2_STRAIGHT * straight ;
2020-05-15 11:18:42 +02:00
straight = NULL ;
curve = NULL ;
InitCivState ( pCivCarToGetIn , NULL ) ;
2020-05-19 18:57:43 +02:00
uVar2 = * pCivCarToGetIn - > ai . padid ;
2020-05-15 11:18:42 +02:00
if ( ( uVar2 & 0xffffe000 ) = = 0 & & ( uVar2 & 0x1fff ) < NumDriver2Straights & & uVar2 > - 1 )
{
2020-04-03 00:44:09 +02:00
straight = Driver2StraightsPtr + uVar2 ;
}
2020-05-15 11:18:42 +02:00
else
{
curve = Driver2CurvesPtr + uVar2 - 0x4000 ;
2020-04-03 00:44:09 +02:00
}
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
}
// decompiled code
// original method signature:
// void /*$ra*/ CopStand(struct PEDESTRIAN *pPed /*$s0*/)
// line 2353, offset 0x00072da0
/* begin block 1 */
// Start line: 2354
// Start offset: 0x00072DA0
// Variables:
// struct VECTOR v; // stack offset -24
/* end block 1 */
// End offset: 0x00072DFC
// End Line: 2377
/* begin block 2 */
// Start line: 18683
/* end block 2 */
// End Line: 18684
/* begin block 3 */
// Start line: 4706
/* end block 3 */
// End Line: 4707
2020-05-15 11:18:42 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void CopStand ( PEDESTRIAN * pPed )
{
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 ;
pPed - > dir . vy = 0x400 - ratan2 ( v . vz , v . vx ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ PedDoNothing(struct PEDESTRIAN *pPed /*$s0*/)
// line 2385, offset 0x0006f2dc
/* begin block 1 */
// Start line: 5187
/* end block 1 */
// End Line: 5188
/* begin block 2 */
// Start line: 5332
/* end block 2 */
// End Line: 5333
2020-05-15 11:36:25 +02:00
int iAllowWatch = 0 ;
// [D]
2020-03-27 21:47:29 +01:00
void PedDoNothing ( PEDESTRIAN * pPed )
{
2020-05-15 11:36:25 +02:00
pPed - > speed = 0 ;
if ( ( pPed - > flags & 0x10U ) = = 0 )
{
2020-04-03 00:44:09 +02:00
SetupDoNowt ( pPed ) ;
pPed - > flags = pPed - > flags | 0x10 ;
}
2020-05-15 11:36:25 +02:00
if ( ( tannerPad & 0x1040 ) ! = 0 )
{
2020-06-22 19:50:29 +02:00
pPed - > interest = 0 ;
2020-06-22 20:29:02 +02:00
pPed - > flags & = ~ 0x10 ;
2020-05-15 11:36:25 +02:00
pPed - > fpAgitatedState = PedUserRunner ;
2020-04-03 00:44:09 +02:00
SetupRunner ( pPed ) ;
2020-05-15 11:36:25 +02:00
2020-04-03 00:44:09 +02:00
goto LAB_0006f530 ;
}
2020-05-15 11:36:25 +02:00
if ( ( tannerPad & 0x4080 ) ! = 0 )
{
2020-06-22 19:50:29 +02:00
pPed - > interest = 0 ;
2020-06-22 20:29:02 +02:00
pPed - > flags & = ~ 0x10 ;
2020-05-15 11:36:25 +02:00
pPed - > fpAgitatedState = PedUserWalker ;
2020-04-03 00:44:09 +02:00
SetupBack ( pPed ) ;
2020-05-15 11:36:25 +02:00
2020-04-03 00:44:09 +02:00
goto LAB_0006f530 ;
}
2020-05-15 11:36:25 +02:00
if ( ( tannerPad & 0x2000 ) = = 0 )
{
if ( ( tannerPad & 0x8000 ) = = 0 )
{
pPed - > frame1 = 0 ;
2020-06-22 19:50:29 +02:00
pPed - > interest + + ; // idle timer is this now
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +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 ;
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( 0 < pPed - > doing_turn )
2020-05-15 11:36:25 +02:00
{
2020-06-22 19:50:29 +02:00
pPed - > doing_turn = 0 ;
2020-04-03 00:44:09 +02:00
goto LAB_0006f4a8 ;
}
}
2020-05-15 11:36:25 +02:00
else
{
2020-04-03 00:44:09 +02:00
LAB_0006f4a8 :
2020-06-22 19:50:29 +02:00
if ( 0 < pPed - > doing_turn )
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-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( pPed - > doing_turn ! = 0 )
2020-05-15 11:36:25 +02:00
{
2020-06-22 19:50:29 +02:00
if ( pPed - > doing_turn < 0 )
pPed - > dir . vy = pPed - > dir . vy + 64 - ( pPed - > doing_turn + tannerTurnMax ) * tannerTurnStep ;
2020-05-15 11:36:25 +02:00
else
2020-06-22 19:50:29 +02:00
pPed - > dir . vy = pPed - > dir . vy - 64 + ( tannerTurnMax - pPed - > doing_turn ) * tannerTurnStep ;
2020-04-03 00:44:09 +02:00
}
2020-06-22 19:50:29 +02:00
2020-04-03 00:44:09 +02:00
goto LAB_0006f530 ;
}
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
pPed - > interest = 0 ;
pPed - > doing_turn + = 2 ;
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( tannerTurnMax < pPed - > doing_turn )
pPed - > doing_turn = tannerTurnMax ;
2020-05-15 11:36:25 +02:00
pPed - > frame1 + + ;
2020-06-22 19:50:29 +02:00
pPed - > dir . vy + = - 64 + ( tannerTurnMax - pPed - > doing_turn ) * tannerTurnStep ;
2020-05-15 11:36:25 +02:00
if ( pPed - > frame1 > 15 )
pPed - > frame1 = 0 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 11:36:25 +02:00
else
{
2020-06-22 19:50:29 +02:00
pPed - > interest = 0 ;
pPed - > doing_turn - = 2 ;
2020-05-15 11:36:25 +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-06-22 19:50:29 +02:00
pPed - > dir . vy + = 64 - ( pPed - > doing_turn + tannerTurnMax ) * tannerTurnStep ;
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( pPed - > frame1 = = 0 )
pPed - > frame1 = 15 ;
2020-05-15 11:36:25 +02:00
else
2020-06-22 19:50:29 +02:00
pPed - > frame1 - - ;
2020-04-03 00:44:09 +02:00
}
pPed - > head_rot = 0 ;
2020-05-15 11:36:25 +02:00
2020-03-27 21:47:29 +01:00
LAB_0006f530 :
2020-06-22 19:50:29 +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 ;
pPed - > fpAgitatedState = PedCarryOutAnimation ;
2020-06-22 19:50:29 +02:00
pPed - > interest = - 2 ;
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
}
// decompiled code
// original method signature:
// void /*$ra*/ PedUserRunner(struct PEDESTRIAN *pPed /*$s0*/)
// line 2523, offset 0x0006f5ac
/* begin block 1 */
// Start line: 2524
// Start offset: 0x0006F5AC
/* end block 1 */
// End offset: 0x0006F80C
// End Line: 2632
/* begin block 2 */
// Start line: 5640
/* end block 2 */
// End Line: 5641
2020-05-15 11:36:25 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void PedUserRunner ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02: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
if ( ( tannerPad & 0x1040 ) = = 0 )
{
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-06-22 19:50:29 +02:00
else
2020-05-15 11:36:25 +02:00
{
if ( bStopTanner = = 0 )
pPed - > speed = 40 - ( tannerDeathTimer > > 1 ) ;
2020-06-22 19:50:29 +02:00
else
2020-05-15 11:36:25 +02:00
pPed - > speed = 0 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( ( tannerPad & 0x2000 ) ! = 0 )
{
pPed - > doing_turn - = 2 ;
2020-05-15 11:36:25 +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-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( pPed - > dir . vz > - 80 )
pPed - > dir . vz - = 20 ;
pPed - > dir . vy = pPed - > dir . vy + 64 - ( pPed - > doing_turn + tannerTurnMax ) * tannerTurnStep ;
AnimatePed ( pPed ) ;
return ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( ( tannerPad & 0x8000 ) ! = 0 )
2020-05-15 11:36:25 +02:00
{
2020-06-22 19:50:29 +02:00
pPed - > doing_turn + = 2 ;
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( tannerTurnMax < pPed - > doing_turn )
pPed - > doing_turn = tannerTurnMax ;
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
pPed - > head_rot = 0 ;
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( pPed - > dir . vz < 80 )
pPed - > dir . vz + = 20 ;
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
pPed - > dir . vy = pPed - > dir . vy - 64 + ( tannerTurnMax - pPed - > doing_turn ) * tannerTurnStep ;
AnimatePed ( pPed ) ;
return ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
if ( pPed - > dir . vz < 0 )
pPed - > dir . vz + = 20 ;
else if ( pPed - > dir . vz > 0 )
pPed - > dir . vz - = 20 ;
2020-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +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 )
2020-05-15 11:36:25 +02:00
{
2020-06-22 19:50:29 +02:00
pPed - > doing_turn = 0 ;
2020-04-03 00:44:09 +02:00
goto code_r0x0006f79c ;
}
}
2020-05-15 11:36:25 +02:00
else
{
2020-04-03 00:44:09 +02:00
code_r0x0006f79c :
2020-06-22 19:50:29 +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-05-15 11:36:25 +02:00
2020-06-22 19:50:29 +02:00
pPed - > dir . vy = pPed - > dir . vy - 64 + ( tannerTurnMax - pPed - > doing_turn ) * tannerTurnStep ;
2020-04-03 00:44:09 +02:00
AnimatePed ( pPed ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ PedUserWalker(struct PEDESTRIAN *pPed /*$s0*/)
// line 2639, offset 0x00072944
/* begin block 1 */
// Start line: 2640
// Start offset: 0x00072944
// Variables:
// static int speed; // offset 0x80
/* end block 1 */
// End offset: 0x00072A10
// End Line: 2694
/* begin block 2 */
// Start line: 17115
/* end block 2 */
// End Line: 17116
/* begin block 3 */
// Start line: 5278
/* end block 3 */
// End Line: 5279
2020-05-15 11:36:25 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void PedUserWalker ( PEDESTRIAN * pPed )
{
2020-05-15 11:36:25 +02:00
if ( ( pPed - > flags & 0x10U ) = = 0 )
{
2020-04-03 00:44:09 +02:00
SetupWalker ( pPed ) ;
}
2020-05-15 11:36:25 +02:00
if ( ( tannerPad & 0x4080 ) = = 0 )
{
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
else
{
2020-04-03 00:44:09 +02:00
pPed - > speed = - 10 ;
}
2020-05-15 11:36:25 +02:00
if ( ( tannerPad & 0x2000 ) ! = 0 )
{
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
if ( ( tannerPad & 0x8000 ) ! = 0 )
{
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
}
// decompiled code
// original method signature:
// void /*$ra*/ PedCarryOutAnimation(struct PEDESTRIAN *pPed /*$s0*/)
// line 2702, offset 0x00072a10
/* begin block 1 */
// Start line: 17238
/* end block 1 */
// End Line: 17239
/* begin block 2 */
// Start line: 17247
/* end block 2 */
// End Line: 17248
2020-05-15 11:36:25 +02:00
int iFreezeTimer = 0 ;
int bFreezeAnimation = 0 ;
int allreadydone = 0 ;
// [D]
2020-03-27 21:47:29 +01:00
void PedCarryOutAnimation ( PEDESTRIAN * pPed )
{
2020-05-15 11:36:25 +02:00
pPed - > speed = 0 ;
if ( tannerPad ! = 0 )
{
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
if ( bFreezeAnimation = = 0 )
{
2020-04-03 00:44:09 +02:00
AnimatePed ( pPed ) ;
}
2020-05-15 11:36:25 +02:00
else
{
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
{
if ( pPed - > type = = PED_ACTION_TIME )
{
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-05-15 11:36:25 +02:00
else
{
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
}
// decompiled code
// original method signature:
// void /*$ra*/ PedGetOutCar(struct PEDESTRIAN *pPed /*$s0*/)
// line 2796, offset 0x00072bec
/* begin block 1 */
// Start line: 17673
/* end block 1 */
// End Line: 17674
/* begin block 2 */
// Start line: 5592
/* end block 2 */
// End Line: 5593
2020-05-15 11:53:03 +02:00
_CAR_DATA * carToGetIn ;
int bReverseYRotation = 0 ;
// [D]
2020-03-27 21:47:29 +01:00
void PedGetOutCar ( PEDESTRIAN * pPed )
{
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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupGetOutCar(struct PEDESTRIAN *pPed /*$s5*/, struct _CAR_DATA *pCar /*$s3*/, int side /*$s7*/)
// line 2827, offset 0x0006f80c
/* begin block 1 */
// Start line: 2828
// Start offset: 0x0006F80C
// Variables:
// int alpha; // $s2
// long disp[4]; // stack offset -80
// long dir[4]; // stack offset -64
// struct SVECTOR vert; // stack offset -48
// int x; // $s4
// int z; // $s0
// int a; // $s6
// int nx; // $a3
// int nz; // $a1
/* end block 1 */
// End offset: 0x0006FA3C
// End Line: 2891
/* begin block 2 */
// Start line: 6072
/* end block 2 */
// End Line: 6073
/* begin block 3 */
// Start line: 6268
/* end block 3 */
// End Line: 6269
2020-05-15 11:53:03 +02:00
int lastCarCameraView = 0 ;
// [D]
2020-04-03 00:44:09 +02:00
void SetupGetOutCar ( PEDESTRIAN * pPed , _CAR_DATA * pCar , int side )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
bool bVar1 ;
short sVar2 ;
int iVar3 ;
uint uVar4 ;
int iVar5 ;
int iVar6 ;
int iVar7 ;
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 ;
iVar5 = pCar - > hd . direction ;
iVar6 = pCar - > hd . direction ;
2020-04-03 00:44:09 +02:00
iVar3 = rsin ( iVar6 ) ;
sVar2 = rcos ( iVar6 ) ;
iVar7 = 400 ;
2020-05-15 11:53:03 +02:00
2020-05-20 17:33:53 +02:00
bVar1 = - 1 < sVar2 * ( pCar - > hd . where . t [ 0 ] - pPed - > position . vx ) - FIXED ( iVar3 * 0x1000 ) * ( pCar - > hd . where . t [ 2 ] - pPed - > position . vz ) + 0x800 ;
2020-05-15 11:53:03 +02:00
if ( bVar1 )
sVar2 = iVar6 - 0x400 ;
else
sVar2 = iVar6 + 0x400 ;
bReverseYRotation = ! bVar1 ;
pPed - > dir . vy = sVar2 ;
if ( side = = 1 )
2020-04-03 00:44:09 +02:00
iVar7 = - 400 ;
2020-05-15 11:53:03 +02:00
2020-04-03 00:44:09 +02:00
uVar4 = iVar5 + 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-06-06 12:29:36 +02:00
player [ playerId ] . cameraPos . vx = pCar - > hd . where . t [ 0 ] - ( FIXED ( iVar7 * rcossin_tbl [ uVar4 * 2 + 1 ] ) - FIXED ( rcossin_tbl [ uVar4 * 2 ] * 800 ) ) ;
player [ playerId ] . cameraPos . vy = - 200 - pCar - > hd . where . t [ 1 ] ;
player [ playerId ] . cameraPos . vz = pCar - > hd . where . t [ 2 ] + ( FIXED ( iVar7 * rcossin_tbl [ uVar4 * 2 ] ) + FIXED ( rcossin_tbl [ uVar4 * 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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupGetInCar(struct PEDESTRIAN *pPed /*$s2*/)
// line 2898, offset 0x0006fa3c
/* begin block 1 */
// Start line: 2899
// Start offset: 0x0006FA3C
// Variables:
// int alpha; // $s1
// long disp[4]; // stack offset -72
// long dir[4]; // stack offset -56
// struct SVECTOR vert; // stack offset -40
/* begin block 1.1 */
// Start line: 2934
// Start offset: 0x0006FB2C
// Variables:
// int x; // $t1
// int z; // $t2
// int a; // $a0
// int nx; // $a3
// int nz; // $a1
/* end block 1.1 */
// End offset: 0x0006FC24
// End Line: 2957
/* begin block 1.2 */
// Start line: 2968
// Start offset: 0x0006FC70
// Variables:
// long pos[4]; // stack offset -32
/* end block 1.2 */
// End offset: 0x0006FC70
// End Line: 2969
/* end block 1 */
// End offset: 0x0006FD08
// End Line: 2988
/* begin block 2 */
// Start line: 6510
/* end block 2 */
// End Line: 6511
/* begin block 3 */
// Start line: 6518
/* end block 3 */
// End Line: 6519
/* begin block 4 */
// Start line: 6525
/* end block 4 */
// End Line: 6526
2020-05-15 11:53:03 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupGetInCar ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
short sVar2 ;
int iVar3 ;
uint uVar4 ;
int iVar5 ;
int iVar6 ;
2020-05-15 11:53:03 +02:00
long pos [ 4 ] ;
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
iVar6 = carToGetIn - > hd . direction ;
2020-04-03 00:44:09 +02:00
iVar3 = rsin ( iVar6 ) ;
sVar2 = rcos ( iVar6 ) ;
2020-05-15 11:53:03 +02:00
2020-05-20 17:33:53 +02:00
if ( sVar2 * ( carToGetIn - > hd . where . t [ 0 ] - pPed - > position . vx ) - FIXED ( iVar3 * 0x1000 ) * ( carToGetIn - > hd . where . t [ 2 ] - pPed - > position . vz ) + 0x800 < 0 )
2020-04-03 00:44:09 +02:00
iVar6 = iVar6 + 0x400 ;
2020-05-15 11:53:03 +02:00
else
iVar6 = iVar6 - 0x400 ;
2020-04-03 00:44:09 +02:00
iVar5 = 400 ;
2020-05-15 11:53:03 +02:00
pPed - > dir . vy = iVar6 ;
iVar3 = carToGetIn - > hd . direction ;
if ( iVar3 < iVar6 )
2020-04-03 00:44:09 +02:00
iVar5 = - 400 ;
2020-05-15 11:53:03 +02:00
2020-04-03 00:44:09 +02:00
uVar4 = iVar3 + 0x800U & 0xfff ;
2020-05-15 11:53:03 +02:00
2020-05-15 14:41:42 +02:00
if ( NoPlayerControl = = 0 & & gInGameCutsceneActive = = 0 )
2020-05-15 11:53:03 +02:00
{
player [ 0 ] . cameraView = 5 ;
2020-05-20 17:46:52 +02:00
player [ 0 ] . cameraPos . vx = carToGetIn - > hd . where . t [ 0 ] - ( FIXED ( iVar5 * rcossin_tbl [ uVar4 * 2 + 1 ] ) - FIXED ( rcossin_tbl [ uVar4 * 2 ] * 800 ) ) ;
2020-05-15 11:53:03 +02:00
player [ 0 ] . cameraPos . vy = - 200 - carToGetIn - > hd . where . t [ 1 ] ;
2020-05-20 17:46:52 +02:00
player [ 0 ] . cameraPos . vz = carToGetIn - > hd . where . t [ 2 ] + ( FIXED ( iVar5 * rcossin_tbl [ uVar4 * 2 ] ) + FIXED ( rcossin_tbl [ uVar4 * 2 + 1 ] * 800 ) ) ;
2020-05-15 11:53:03 +02:00
}
if ( ( carToGetIn - > controlFlags & 4 ) = = 0 )
{
2020-09-27 11:03:11 +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
{
carToGetIn - > controlFlags | = 4 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 11:53:03 +02:00
else
{
pos [ 0 ] = player [ 0 ] . pos [ 0 ] ;
pos [ 1 ] = - player [ 0 ] . pos [ 1 ] ;
pos [ 2 ] = player [ 0 ] . pos [ 2 ] ;
2020-05-15 14:41:42 +02:00
// HEY!
2020-05-15 11:53:03 +02:00
CreatePedAtLocation ( & pos , 8 ) ;
Start3DSoundVolPitch ( - 1 , 6 , 5 , pos [ 0 ] , pos [ 1 ] , pos [ 2 ] , 0 , 0x1000 ) ;
carToGetIn - > controlFlags | = 4 ;
2020-04-03 00:44:09 +02:00
}
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ PedGetInCar(struct PEDESTRIAN *pPed /*$s0*/)
// line 2994, offset 0x00072b5c
/* begin block 1 */
// Start line: 2995
// Start offset: 0x00072B5C
// Variables:
// long disp[4]; // stack offset -48
// long dir[4]; // stack offset -32
// struct SVECTOR vert; // stack offset -16
/* end block 1 */
// End offset: 0x00072BEC
// End Line: 3018
/* begin block 2 */
// Start line: 17840
/* end block 2 */
// End Line: 17841
2020-05-15 11:53:03 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void PedGetInCar ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
_CAR_DATA * newCar ;
int playerID ;
2020-05-15 11:53:03 +02:00
pPed - > speed = 0 ;
if ( pPed - > frame1 < 0xf )
{
2020-04-03 00:44:09 +02:00
AnimatePed ( pPed ) ;
}
2020-05-15 11:53:03 +02:00
else
{
2020-04-03 00:44:09 +02:00
playerID = ( int ) pPed - > padId ;
2020-05-15 11:53:03 +02:00
pPed - > speed = 0 ;
2020-04-03 00:44:09 +02:00
newCar = carToGetIn ;
2020-05-15 11:53:03 +02:00
pPed - > fpAgitatedState = NULL ;
if ( playerID < 0 )
2020-04-03 00:44:09 +02:00
playerID = - playerID ;
2020-05-15 11:53:03 +02:00
2020-06-22 20:29:02 +02:00
pPed - > flags & = ~ 0x10 ;
2020-05-15 11:53:03 +02:00
2020-04-03 00:44:09 +02:00
ChangePedPlayerToCar ( playerID , newCar ) ;
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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupPressButton(struct PEDESTRIAN *pPed /*$s0*/)
// line 3026, offset 0x00072904
/* begin block 1 */
// Start line: 17494
/* end block 1 */
// End Line: 17495
/* begin block 2 */
// Start line: 6052
/* end block 2 */
// End Line: 6053
2020-05-15 11:53:03 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupPressButton ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
pPed - > type = PED_ACTION_PRESSBUTTON ;
SetupPedMotionData ( pPed ) ;
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
}
// decompiled code
// original method signature:
// void /*$ra*/ PedPressButton(struct PEDESTRIAN *pPed /*$v1*/)
// line 3040, offset 0x00072c90
/* begin block 1 */
// Start line: 18175
/* end block 1 */
// End Line: 18176
2020-05-15 12:00:42 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void PedPressButton ( PEDESTRIAN * pPed )
{
2020-05-15 12:00:42 +02:00
if ( pPed - > frame1 < 0xf )
{
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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupTannerSitDown(struct PEDESTRIAN *pPed /*$s0*/)
// line 3060, offset 0x000728c8
/* begin block 1 */
// Start line: 6120
/* end block 1 */
// End Line: 6121
2020-05-15 12:00:42 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupTannerSitDown ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
pPed - > type = PED_ACTION_SIT ;
SetupPedMotionData ( pPed ) ;
2020-03-27 21:47:29 +01:00
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
// decompiled code
// original method signature:
// void /*$ra*/ TannerCameraHandler(struct PEDESTRIAN *pPed /*$a0*/)
// line 3074, offset 0x0006fd08
/* begin block 1 */
// Start line: 3076
// Start offset: 0x0006FD08
// Variables:
// int padsteer; // $a3
// int maxY; // $t1
// int maxX; // $t5
// int range; // $t0
// int minX; // $t4
// int extra; // $a3
/* end block 1 */
// End offset: 0x0006FF48
// End Line: 3150
/* begin block 2 */
// Start line: 6830
/* end block 2 */
// End Line: 6831
/* begin block 3 */
// Start line: 6917
/* end block 3 */
// End Line: 6918
/* begin block 4 */
// Start line: 6918
/* end block 4 */
// End Line: 6919
/* begin block 5 */
// Start line: 6927
/* end block 5 */
// End Line: 6928
/* WARNING: Removing unreachable block (ram,0x0006fe58) */
/* WARNING: Removing unreachable block (ram,0x0006fde0) */
/* WARNING: Removing unreachable block (ram,0x0006fe8c) */
2020-05-15 13:38:32 +02:00
2020-05-15 12:00:42 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void TannerCameraHandler ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
int iVar1 ;
short sVar2 ;
int iVar3 ;
2020-05-15 12:00:42 +02:00
int padid = player [ 0 ] . padid ;
camera_position . vy = pPed - > head_pos - 28 - player [ 0 ] . pos [ 1 ] ;
if ( Pads [ padid ] . type = = 4 )
{
iVar3 = Pads [ padid ] . mapanalog [ 0 ] ;
if ( iVar3 < - 32 | | iVar3 > 32 )
{
2020-04-03 00:44:09 +02:00
iVar1 = iVar3 ;
2020-05-15 12:00:42 +02:00
if ( iVar3 < 0 )
2020-04-03 00:44:09 +02:00
iVar1 = - iVar3 ;
2020-05-15 12:00:42 +02:00
tannerLookAngle . vy = ( iVar1 - 32 ) * 9 ;
if ( iVar3 < 0 )
tannerLookAngle . vy = ( iVar1 - 32 ) * - 9 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:00:42 +02:00
else
{
2020-04-03 00:44:09 +02:00
tannerLookAngle . vy = 0 ;
}
2020-05-15 12:00:42 +02:00
tannerLookAngle . vx = - Pads [ padid ] . mapanalog [ 1 ] ;
if ( tannerLookAngle . vx < - 32 )
tannerLookAngle . vx = tannerLookAngle . vx - 128 ;
else if ( tannerLookAngle . vx < 33 )
tannerLookAngle . vx = 0 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:00:42 +02:00
else
{
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
if ( ( padd & 1U ) = = 0 )
{
2020-04-03 00:44:09 +02:00
sVar2 = 0 ;
2020-05-15 12:00:42 +02:00
if ( ( padd & 2U ) ! = 0 )
{
2020-04-03 00:44:09 +02:00
sVar2 = - 0x400 ;
}
}
2020-05-15 12:00:42 +02:00
else
{
2020-04-03 00:44:09 +02:00
sVar2 = 0x400 ;
2020-05-15 12:00:42 +02:00
if ( ( padd & 2U ) ! = 0 )
{
2020-04-03 00:44:09 +02:00
sVar2 = 0x800 ;
}
}
2020-06-22 19:50:29 +02:00
2020-05-15 12:00:42 +02:00
camera_position . vx = player [ 0 ] . pos [ 0 ] ;
camera_position . vz = player [ 0 ] . pos [ 2 ] ;
camera_angle . vx = camAngle . vx + tannerLookAngle . vx ;
camera_angle . vy = ( camAngle . vy - tannerLookAngle . vy ) + sVar2 & 0xfff ;
camera_angle . vz = camAngle . vz + tannerLookAngle . vz ;
tracking_car = 0 ;
player [ 0 ] . cameraPos . vx = player [ 0 ] . pos [ 0 ] ;
player [ 0 ] . cameraPos . vy = camera_position . vy ;
player [ 0 ] . cameraPos . vz = player [ 0 ] . pos [ 2 ] ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ TannerSitDown(struct PEDESTRIAN *pPed /*$a2*/)
// line 3157, offset 0x0006ff48
/* begin block 1 */
// Start line: 3158
// Start offset: 0x0006FF48
// Variables:
// struct VECTOR angle; // stack offset -24
/* end block 1 */
// End offset: 0x000700D0
// End Line: 3219
/* begin block 2 */
// Start line: 7110
/* end block 2 */
// End Line: 7111
/* begin block 3 */
// Start line: 7118
/* end block 3 */
// End Line: 7119
2020-05-15 12:00:42 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void TannerSitDown ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
int iVar2 ;
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
if ( pPed - > frame1 = = 15 )
{
2020-06-22 20:10:11 +02:00
if ( ( pPed - > flags & 4U ) = = 0 )
2020-05-15 12:00:42 +02:00
{
2020-06-22 19:50:29 +02:00
oldCamView = player [ pPed - > padId ] . cameraView ;
2020-04-03 00:44:09 +02:00
bFreezeAnimation = 1 ;
2020-05-15 12:00:42 +02:00
2020-06-22 20:00:23 +02:00
/*
2020-06-22 19:50:29 +02:00
if ( player [ pPed - > padId ] . cameraView = = 2 )
2020-06-22 20:00:23 +02:00
pPed - > flags | = 4 ;
2020-05-15 12:00:42 +02:00
else
2020-06-22 19:50:29 +02:00
pPed - > flags & = ~ 4 ;
2020-06-22 20:00:23 +02:00
*/
2020-05-15 12:00:42 +02:00
if ( ( tannerPad & 0x10 ) = = 0 )
2020-04-03 00:44:09 +02:00
return ;
2020-05-15 12:00:42 +02:00
tracking_car = 1 ;
2020-06-22 20:10:11 +02:00
pPed - > flags | = 4 ; // new reverse animation flag
2020-04-03 00:44:09 +02:00
bFreezeAnimation = 0 ;
2020-05-15 12:00:42 +02:00
2020-04-03 00:44:09 +02:00
oldCamView = - 1 ;
return ;
}
2020-06-22 19:50:29 +02:00
2020-04-03 00:44:09 +02:00
LAB_00070054 :
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-05-15 12:00:42 +02:00
2020-04-03 00:44:09 +02:00
return ;
}
2020-05-15 12:00:42 +02:00
2020-06-22 20:10:11 +02:00
if ( ( pPed - > flags & 4 ) ! = 0 )
2020-05-15 12:00:42 +02:00
{
iVar2 = pPed - > position . vy - 2 ;
2020-04-03 00:44:09 +02:00
goto LAB_000700b4 ;
}
}
2020-05-15 12:00:42 +02:00
else
{
2020-06-22 20:10:11 +02:00
if ( ( pPed - > flags & 4 ) ! = 0 )
2020-05-15 12:00:42 +02:00
goto LAB_00070054 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:00:42 +02:00
iVar2 = pPed - > position . vy + 2 ;
2020-03-27 21:47:29 +01:00
LAB_000700b4 :
2020-05-15 12:00:42 +02:00
pPed - > position . vy = iVar2 ;
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
}
// decompiled code
// original method signature:
// void /*$ra*/ AnimatePed(struct PEDESTRIAN *pPed /*$s0*/)
// line 3227, offset 0x000700d0
/* begin block 1 */
// Start line: 3228
// Start offset: 0x000700D0
/* begin block 1.1 */
// Start line: 3238
// Start offset: 0x000700F0
// Variables:
// int mapheight; // $a3
// int reverse; // $s1
/* begin block 1.1.1 */
// Start line: 3241
// Start offset: 0x000700F0
// Variables:
// struct VECTOR vec; // stack offset -32
/* end block 1.1.1 */
// End offset: 0x0007015C
// End Line: 3266
/* begin block 1.1.2 */
// Start line: 3330
// Start offset: 0x0007030C
// Variables:
// int sfc; // $v1
/* end block 1.1.2 */
// End offset: 0x000703BC
// End Line: 3335
/* end block 1.1 */
// End offset: 0x00070468
// End Line: 3348
/* end block 1 */
// End offset: 0x00070468
// End Line: 3350
/* begin block 2 */
// Start line: 7270
/* end block 2 */
// End Line: 7271
/* begin block 3 */
// Start line: 7279
/* end block 3 */
// End Line: 7280
/* begin block 4 */
// Start line: 7285
/* end block 4 */
// End Line: 7286
2020-05-15 12:33:29 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void AnimatePed ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
PED_ACTION_TYPE PVar2 ;
ushort uVar3 ;
int iVar5 ;
2020-05-15 12:33:29 +02:00
unsigned char bVar6 ;
2020-04-03 00:44:09 +02:00
uint uVar7 ;
long lVar8 ;
2020-05-15 12:33:29 +02:00
VECTOR vec ;
if ( pauseflag )
return ;
vec . vx = pPed - > position . vx ;
vec . vz = pPed - > position . vz ;
vec . vy = - pPed - > position . vy ;
if ( pPed - > pedType = = CIVILIAN & & ( pPed - > flags & 0x8000U ) ! = 0 )
{
iVar5 = MapHeight ( & vec ) ;
2020-06-22 19:50:29 +02:00
lVar8 = - 60 - iVar5 ;
2020-05-15 12:33:29 +02:00
}
else
{
iVar5 = MapHeight ( & vec ) ;
2020-06-22 19:50:29 +02:00
lVar8 = - 130 - iVar5 ;
2020-05-15 12:33:29 +02:00
}
2020-05-16 19:10:15 +02:00
PVar2 = pPed - > type ;
2020-06-22 19:50:29 +02:00
if ( pPed - > speed < 0 )
2020-05-15 12:33:29 +02:00
{
2020-06-22 19:50:29 +02:00
uVar3 = pPed - > dir . vy ;
pPed - > position . vx = pPed - > position . vx - FIXED ( pPed - > speed * rcossin_tbl [ ( uVar3 & 0xfff ) * 2 ] ) ;
iVar5 = pPed - > position . vz - FIXED ( pPed - > speed * rcossin_tbl [ ( - uVar3 & 0xfffU ) * 2 + 1 ] ) ; // [A] is it valid?
2020-05-15 12:33:29 +02:00
}
2020-05-16 19:10:15 +02:00
else
2020-05-15 12:33:29 +02:00
{
2020-06-22 19:50:29 +02:00
uVar7 = ( int ) pPed - > dir . vy - 0x800U & 0xfff ;
pPed - > position . vx = pPed - > position . vx + FIXED ( ( int ) pPed - > speed * ( int ) rcossin_tbl [ uVar7 * 2 ] ) ;
iVar5 = pPed - > position . vz + FIXED ( ( int ) pPed - > speed * ( int ) rcossin_tbl [ uVar7 * 2 + 1 ] ) ;
2020-05-15 12:33:29 +02:00
}
pPed - > position . vz = iVar5 ;
if ( PVar2 ! = PED_ACTION_SIT & & PVar2 ! = PED_ACTION_COPCROUCH & & PVar2 ! = PED_ACTION_COPSTAND )
{
pPed - > position . vy = lVar8 ;
pPed - > velocity . vy = 10 ;
}
2020-06-28 23:31:45 +02:00
if ( ( pPed - > flags & 4 ) = = 0 ) // || pPed->pedType != TANNER_MODEL)
2020-05-15 12:33:29 +02:00
{
2020-05-15 13:38:32 +02:00
pPed - > frame1 + + ;
2020-05-15 12:33:29 +02:00
2020-05-15 14:21:21 +02:00
if ( ( uint ) pPed - > type - 8 < 3 ) // [A] TODO: figure out what type it is to have extended frames
bVar6 = 31 ;
else
bVar6 = 16 ;
2020-05-15 12:33:29 +02:00
2020-05-15 14:21:21 +02:00
if ( pPed - > frame1 > = bVar6 )
2020-05-15 12:33:29 +02:00
pPed - > frame1 = 0 ;
}
else
{
if ( pPed - > frame1 = = 0 )
pPed - > frame1 = 15 ;
pPed - > frame1 - - ;
}
2020-09-04 21:08:51 +02:00
if ( ( pPed - > pedType = = TANNER_MODEL | | ( ActiveCheats . cheat12 & & ( pPed - > pedType = = OTHER_MODEL ) ) ) & & pPed - > type < PED_ACTION_BACK )
2020-05-15 12:33:29 +02:00
{
iVar5 = PedSurfaceType ( ( VECTOR * ) & pPed - > position ) ;
if ( iVar5 ! = 4 & & iVar5 ! = 6 & & iVar5 ! = 11 & & iVar5 ! = 9 )
{
if ( pPed - > frame1 = = 3 )
Start3DSoundVolPitch ( - 1 , 6 , 0 , pPed - > position . vx , pPed - > position . vy , pPed - > position . vz , - 5000 , 0x1000 ) ;
if ( pPed - > frame1 = = 11 )
Start3DSoundVolPitch ( - 1 , 6 , 1 , pPed - > position . vx , pPed - > position . vy , pPed - > position . vz , - 5000 , 0x1000 ) ;
2020-04-03 00:44:09 +02:00
}
}
2020-05-15 12:33:29 +02:00
if ( pPed - > pedType ! = CIVILIAN )
{
iVar5 = pPed - > padId ;
if ( iVar5 < 0 )
iVar5 = - iVar5 ;
player [ iVar5 ] . pos [ 0 ] = pPed - > position . vx ;
iVar5 = pPed - > padId ;
if ( iVar5 < 0 )
iVar5 = - iVar5 ;
player [ iVar5 ] . pos [ 1 ] = - pPed - > position . vy ;
iVar5 = pPed - > padId ;
if ( iVar5 < 0 )
iVar5 = - iVar5 ;
player [ iVar5 ] . pos [ 2 ] = pPed - > position . vz ;
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ DeActivatePlayerPedestrian(struct PEDESTRIAN *pPed /*$s3*/)
// line 3357, offset 0x0007216c
/* begin block 1 */
// Start line: 3358
// Start offset: 0x0007216C
// Variables:
// int distToCarSq; // stack offset -32
// struct _CAR_DATA *closestCar; // $s1
// struct _PLAYER *pPlayer; // $v0
// struct VECTOR point; // stack offset -48
// int getIn; // $s2
/* begin block 1.1 */
// Start line: 3384
// Start offset: 0x0007221C
/* end block 1.1 */
// End offset: 0x00072274
// End Line: 3395
/* end block 1 */
// End offset: 0x00072290
// End Line: 3396
/* begin block 2 */
// Start line: 6714
/* end block 2 */
// End Line: 6715
2020-05-15 12:33:29 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void DeActivatePlayerPedestrian ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
_CAR_DATA * cp ;
2020-06-06 12:29:36 +02:00
int playerId ;
2020-04-03 00:44:09 +02:00
int iVar2 ;
2020-05-15 14:41:42 +02:00
int distToCarSq ;
2020-04-03 00:44:09 +02:00
iVar2 = 0 ;
2020-06-06 12:29:36 +02:00
playerId = pPed - > padId ;
2020-05-15 12:33:29 +02:00
2020-06-06 12:29:36 +02:00
if ( playerId < 0 )
playerId = - playerId ;
2020-05-15 12:33:29 +02:00
2020-06-06 12:29:36 +02:00
cp = FindClosestCar ( player [ playerId ] . pos [ 0 ] , player [ playerId ] . pos [ 1 ] , player [ playerId ] . pos [ 2 ] , & distToCarSq ) ;
2020-05-15 12:33:29 +02:00
2020-05-16 19:10:15 +02:00
if ( ! cp )
return ;
2020-05-15 12:33:29 +02:00
if ( cp - > ap . model = = 4 )
2020-09-18 23:06:17 +02:00
iVar2 = FindPointOfCollision ( cp , pPed ) ;
2020-05-15 14:41:42 +02:00
else if ( cp & & TannerCanEnterCar ( cp , distToCarSq ) )
2020-05-15 12:33:29 +02:00
iVar2 = 1 ;
if ( iVar2 ! = 0 )
{
2020-04-03 00:44:09 +02:00
carToGetIn = cp ;
pPed - > type = PED_ACTION_GETINCAR ;
2020-05-15 12:33:29 +02:00
pPed - > fpAgitatedState = PedGetInCar ;
Start3DSoundVolPitch ( - 1 , 6 , 2 , player [ 0 ] . pos [ 0 ] , player [ 0 ] . pos [ 1 ] , player [ 0 ] . pos [ 2 ] , 0 , 0x1000 ) ;
2020-04-03 00:44:09 +02:00
SetupPedestrian ( pPed ) ;
SetupGetInCar ( pPed ) ;
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CivPedDoNothing(struct PEDESTRIAN *pPed /*$a0*/)
// line 3402, offset 0x00072ce0
/* begin block 1 */
// Start line: 18899
/* end block 1 */
// End Line: 18900
/* begin block 2 */
// Start line: 18900
/* end block 2 */
// End Line: 18901
void CivPedDoNothing ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
return ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupCivPedRouteData(struct VECTOR *pPos /*$s1*/)
// line 3411, offset 0x0007313c
/* begin block 1 */
// Start line: 3412
// Start offset: 0x0007313C
// Variables:
// struct VECTOR baseLoc; // stack offset -32
/* end block 1 */
// End offset: 0x000731F8
// End Line: 3435
/* begin block 2 */
// Start line: 23047
/* end block 2 */
// End Line: 23048
2020-05-15 12:33:29 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupCivPedRouteData ( VECTOR * pPos )
{
2020-05-15 12:33:29 +02:00
VECTOR baseLoc ;
baseLoc . vx = pPos - > vx ;
baseLoc . vy = pPos - > vy ;
baseLoc . vz = pPos - > vz ;
pedestrian_roads . pos = GetSurfaceIndex ( & baseLoc ) ;
baseLoc . vz = pPos - > vz - 128 ;
pedestrian_roads . north = GetSurfaceIndex ( & baseLoc ) ;
baseLoc . vz = pPos - > vz + 128 ;
pedestrian_roads . south = GetSurfaceIndex ( & baseLoc ) ;
baseLoc . vz = pPos - > vz ;
baseLoc . vx = pPos - > vx - 128 ;
pedestrian_roads . east = GetSurfaceIndex ( & baseLoc ) ;
baseLoc . vx = pPos - > vx + 128 ;
pedestrian_roads . west = GetSurfaceIndex ( & baseLoc ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ PingInPedestrians()
// line 3447, offset 0x0007047c
/* begin block 1 */
// Start line: 3449
// Start offset: 0x0007047C
// Variables:
// int bFound; // $s1
// struct VECTOR randomLoc; // stack offset -88
// struct VECTOR baseLoc; // stack offset -72
// int i; // $s2
// int pingInDist; // $a2
// struct VECTOR position; // stack offset -56
// struct VECTOR target; // stack offset -40
// struct PEDESTRIAN *pedestrian; // $s1
/* begin block 1.1 */
// Start line: 3484
// Start offset: 0x00070518
/* begin block 1.1.1 */
// Start line: 3502
// Start offset: 0x000705F8
// Variables:
// struct PEDESTRIAN *pPed; // $a2
/* begin block 1.1.1.1 */
// Start line: 3520
// Start offset: 0x00070628
// Variables:
// int x; // $v1
// int z; // $v0
// int radius; // $v1
/* end block 1.1.1.1 */
// End offset: 0x00070628
// End Line: 3522
/* end block 1.1.1 */
// End offset: 0x00070674
// End Line: 3524
/* end block 1.1 */
// End offset: 0x00070674
// End Line: 3526
/* begin block 1.2 */
// Start line: 3534
// Start offset: 0x000706AC
/* begin block 1.2.1 */
// Start line: 3583
// Start offset: 0x000707F4
// Variables:
// int rval; // $v1
/* end block 1.2.1 */
// End offset: 0x00070858
// End Line: 3622
/* end block 1.2 */
// End offset: 0x00070858
// End Line: 3627
/* end block 1 */
// End offset: 0x00070858
// End Line: 3632
/* begin block 2 */
// Start line: 7739
/* end block 2 */
// End Line: 7740
/* begin block 3 */
// Start line: 7740
/* end block 3 */
// End Line: 7741
/* begin block 4 */
// Start line: 7753
/* end block 4 */
// End Line: 7754
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-06-28 19:59:26 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void PingInPedestrians ( void )
{
2020-04-03 00:44:09 +02:00
bool bVar1 ;
PED_ACTION_TYPE PVar3 ;
long lVar5 ;
PEDESTRIAN * pPed ;
int iVar6 ;
long lVar7 ;
int iVar8 ;
int step ;
2020-06-21 10:49:50 +02:00
VECTOR randomLoc ;
VECTOR baseLoc ;
VECTOR position ;
VECTOR target ;
2020-04-03 00:44:09 +02:00
bVar1 = false ;
2020-06-21 10:49:50 +02:00
if ( num_pedestrians < 15 & & pFreePeds ! = NULL & & pFreePeds - > pNext ! = NULL )
{
baseLoc . vx = player [ 0 ] . pos [ 0 ] ;
baseLoc . vy = player [ 0 ] . pos [ 1 ] ;
baseLoc . vz = player [ 0 ] . pos [ 2 ] ;
if ( gWeather ! = 0 | | FindSeated ( ) = = NULL )
{
2020-04-03 00:44:09 +02:00
step = 0 ;
do {
lVar5 = Random2 ( 0 ) ;
lVar7 = lVar5 ;
2020-06-21 10:49:50 +02:00
2020-04-03 00:44:09 +02:00
pinginPedAngle = pinginPedAngle + 0x51 ;
2020-09-11 09:10:50 +02:00
iVar8 = lVar5 - FixFloorSigned ( lVar7 , 7 ) * 128 + 0x600 ;
2020-06-21 10:49:50 +02:00
randomLoc . vy = baseLoc . vy ;
2020-09-11 11:30:58 +02:00
randomLoc . vx = baseLoc . vx + iVar8 * FIXEDH ( ( int ) rcossin_tbl [ ( pinginPedAngle & 0xfffU ) * 2 ] * 8 ) ;
randomLoc . vz = baseLoc . vz + iVar8 * FIXEDH ( ( int ) rcossin_tbl [ ( pinginPedAngle & 0xfffU ) * 2 + 1 ] * 8 ) ;
2020-06-21 10:49:50 +02:00
iVar8 = MapHeight ( & randomLoc ) ;
randomLoc . vy = - iVar8 ;
if ( ( ( baseLoc . vy + - 0x200 < = iVar8 ) & & ( iVar8 < = baseLoc . vy + 0x200 ) ) & & ( iVar8 = IsPavement ( randomLoc . vx , randomLoc . vy , randomLoc . vz , NULL ) , iVar8 ! = 0 ) )
2020-04-03 00:44:09 +02:00
{
bVar1 = true ;
2020-06-21 10:49:50 +02:00
if ( pUsedPeds = = NULL )
{
2020-04-03 00:44:09 +02:00
LAB_0007068c :
2020-06-21 10:49:50 +02:00
if ( ! bVar1 )
2020-04-03 00:44:09 +02:00
return ;
2020-06-21 10:49:50 +02:00
if ( pFreePeds - > pNext = = NULL )
2020-04-03 00:44:09 +02:00
return ;
2020-06-21 10:49:50 +02:00
2020-04-03 00:44:09 +02:00
pPed = CreatePedestrian ( ) ;
pPed - > flags = 0 ;
2020-06-21 10:49:50 +02:00
pPed - > position . vx = randomLoc . vx ;
pPed - > position . vy = randomLoc . vy ;
pPed - > pedType = CIVILIAN ; // [A] try :D
pPed - > dir . vz = 0 ;
pPed - > dir . vx = 0 ;
pPed - > dir . vy = 0 ;
pPed - > position . vz = randomLoc . vz ;
baseLoc . vx = randomLoc . vx ;
baseLoc . vy = ( pPed - > position ) . vy ;
baseLoc . vz = ( pPed - > position ) . vz ;
step = MapHeight ( & baseLoc ) ;
baseLoc . vy = - step ;
SetupCivPedRouteData ( & baseLoc ) ;
2020-04-03 00:44:09 +02:00
PedestrianActionInit_WalkToTarget ( pPed ) ;
2020-06-21 10:49:50 +02:00
step = - 28 ;
2020-04-03 00:44:09 +02:00
PVar3 = PED_ACTION_CIVRUN ;
2020-06-21 10:49:50 +02:00
if ( ( ( pedestrian_roads . north ! = - 28 & &
( PVar3 = PED_ACTION_CIVRUN , pedestrian_roads . south ! = - 28 ) ) & &
( PVar3 = PED_ACTION_CIVRUN , pedestrian_roads . east ! = - 28 ) ) & &
( PVar3 = PED_ACTION_CIVWALK , pedestrian_roads . west = = - 28 ) )
{
2020-04-03 00:44:09 +02:00
PVar3 = PED_ACTION_CIVRUN ;
}
2020-06-21 10:49:50 +02:00
2020-04-03 00:44:09 +02:00
pPed - > type = PVar3 ;
2020-06-21 10:49:50 +02:00
if ( pPed - > type = = PED_ACTION_CIVRUN ) // [A] fix bug
pPed - > speed = 30 ;
2020-04-03 00:44:09 +02:00
lVar7 = Random2 ( - 0x1c ) ;
lVar5 = Random2 ( step ) ;
2020-06-21 10:49:50 +02:00
pPed - > pallet = lVar7 + ( lVar7 / 5 ) * - 5 + ( lVar5 + ( lVar5 / 5 ) * - 5 ) * 16 ;
2020-04-03 00:44:09 +02:00
SetupPedMotionData ( pPed ) ;
2020-06-21 10:49:50 +02:00
pPed - > fpAgitatedState = NULL ;
pPed - > dir . vy = 0 ;
pPed - > fpRestState = fpPedPersonalityFunctions [ 7 ] ;
2020-04-03 00:44:09 +02:00
lVar7 = Random2 ( 0 ) ;
2020-06-21 10:49:50 +02:00
if ( ( lVar7 / 6 ) * 6 ! = lVar7 + - 3 )
2020-04-03 00:44:09 +02:00
return ;
2020-06-21 10:49:50 +02:00
2020-04-03 00:44:09 +02:00
pPed - > flags = pPed - > flags | 0x4000 ;
return ;
}
2020-06-21 10:49:50 +02:00
iVar6 = pUsedPeds - > position . vx - randomLoc . vx ;
iVar8 = pUsedPeds - > position . vz ;
2020-04-03 00:44:09 +02:00
iVar6 = iVar6 * iVar6 ;
pPed = pUsedPeds ;
2020-06-21 10:49:50 +02:00
while ( bVar1 = true , 15999999 < iVar6 + ( iVar8 - randomLoc . vz ) * ( iVar8 - randomLoc . vz ) )
{
2020-04-03 00:44:09 +02:00
pPed = pPed - > pNext ;
2020-06-21 10:49:50 +02:00
if ( pPed = = NULL )
goto LAB_00070674 ;
iVar6 = ( pPed - > position ) . vx - randomLoc . vx ;
2020-04-03 00:44:09 +02:00
iVar6 = iVar6 * iVar6 ;
iVar8 = ( pPed - > position ) . vz ;
}
bVar1 = false ;
}
2020-06-21 10:49:50 +02:00
2020-04-03 00:44:09 +02:00
LAB_00070674 :
step = step + 1 ;
2020-06-21 10:49:50 +02:00
if ( ( 49 < step ) | | ( bVar1 ) )
goto LAB_0007068c ;
2020-04-03 00:44:09 +02:00
} while ( true ) ;
}
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ TannerCollision(struct PEDESTRIAN *pPed /*$s1*/)
// line 3640, offset 0x00072ee4
/* begin block 1 */
// Start line: 3641
// Start offset: 0x00072EE4
/* end block 1 */
// End offset: 0x00072FBC
// End Line: 3675
/* begin block 2 */
// Start line: 20049
/* end block 2 */
// End Line: 20050
/* begin block 3 */
// Start line: 20050
/* end block 3 */
// End Line: 20051
/* begin block 4 */
// Start line: 21345
/* end block 4 */
// End Line: 21346
2020-05-24 10:22:31 +02:00
_CAR_DATA * pcdTanner ;
// [D]
2020-03-27 21:47:29 +01:00
void TannerCollision ( PEDESTRIAN * pPed )
{
2020-05-24 10:22:31 +02:00
if ( pPed - > type = = PED_ACTION_SIT )
return ;
pcdTanner = & car_data [ 21 ] ;
ClearMem ( ( char * ) pcdTanner , sizeof ( _CAR_DATA ) ) ;
pcdTanner - > id = 21 ;
pcdTanner - > controlType = 6 ;
pcdTanner - > ap . carCos = & dummyCosmetics ;
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 ) ;
TannerCarCollisionCheck ( ( VECTOR * ) & pPed - > position , pPed - > dir . vy , 0 ) ;
pPed - > position . vx = pcdTanner - > hd . where . t [ 0 ] ;
pPed - > position . vz = pcdTanner - > hd . where . t [ 2 ] ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// int /*$ra*/ FindPointOfCollision(struct _CAR_DATA *pCar /*$s3*/, struct VECTOR *pPos /*$a1*/)
// line 3685, offset 0x00070878
/* begin block 1 */
// Start line: 3686
// Start offset: 0x00070878
// Variables:
// int tb1; // $v1
// int tb2; // $v0
// int minX; // $a3
// int maxX; // $t0
// int minZ; // $v0
// int maxZ; // $a0
// int x; // $t1
// int z; // $a1
// int s1; // $a2
// int s2; // $v1
// int carLength[2]; // stack offset -40
// static struct CRET2D collisionResult; // offset 0x0
/* end block 1 */
// End offset: 0x00070A9C
// End Line: 3753
/* begin block 2 */
// Start line: 8376
/* end block 2 */
// End Line: 8377
/* begin block 3 */
// Start line: 8377
/* end block 3 */
// End Line: 8378
2020-05-17 10:21:57 +02:00
// [D]
2020-09-18 23:06:17 +02:00
int FindPointOfCollision ( _CAR_DATA * pCar , PEDESTRIAN * pPed )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
int iVar1 ;
uint uVar2 ;
int iVar3 ;
int iVar4 ;
int iVar5 ;
int iVar6 ;
2020-05-24 10:36:48 +02:00
CDATA2D cd [ 2 ] ;
2020-05-17 10:21:57 +02:00
static CRET2D collisionResult ;
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-05-17 20:03:34 +02:00
cd [ 1 ] . length [ 0 ] = car_cosmetics [ pCar - > ap . model ] . colBox . vz ;
cd [ 1 ] . length [ 1 ] = car_cosmetics [ pCar - > ap . model ] . 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-05-17 20:03:34 +02:00
iVar1 = bcollided2d ( cd , 1 ) ;
if ( iVar1 ! = 0 )
2020-05-17 10:21:57 +02:00
{
2020-05-17 20:03:34 +02:00
bFindCollisionPoint ( cd , & collisionResult ) ;
2020-05-17 10:21:57 +02:00
# if defined(COLLISION_DEBUG) && !defined(PSX)
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 ) ;
CVECTOR bbcv = { 0 , 0 , 250 } ;
CVECTOR rrcv = { 250 , 0 , 0 } ;
CVECTOR yycv = { 250 , 250 , 0 } ;
VECTOR _zero = { 0 , 100 , 0 } ;
VECTOR up = { 0 , 200 , 0 } ;
2020-05-17 20:03:34 +02:00
Debug_AddLineOfs ( _zero , up , cd [ 0 ] . x , rrcv ) ;
2020-05-17 10:21:57 +02:00
2020-05-17 20:03:34 +02:00
Debug_AddLineOfs ( _zero , up , cd [ 1 ] . x , yycv ) ;
2020-05-17 10:21:57 +02:00
Debug_AddLineOfs ( _zero , up , collisionResult . hit , bbcv ) ;
}
# endif
2020-05-17 20:03:34 +02:00
uVar2 = pCar - > ap . model ;
iVar6 = car_cosmetics [ uVar2 ] . colBox . vx ;
2020-05-20 15:48:19 +02:00
iVar4 = 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
iVar5 = iVar6 + 96 ;
2020-05-17 10:21:57 +02:00
iVar3 = car_cosmetics [ uVar2 ] . colBox . vz ;
2020-05-20 15:48:19 +02:00
iVar1 = 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
iVar6 = iVar6 - 96 ;
if ( ( iVar3 - 480 < iVar1 ) & & ( iVar1 < iVar3 - 200 ) )
2020-05-17 10:21:57 +02:00
{
if ( ( iVar6 < iVar4 ) & & ( iVar4 < iVar5 ) )
2020-04-03 00:44:09 +02:00
return 1 ;
2020-05-17 10:21:57 +02:00
if ( ( iVar4 < - iVar6 ) & & ( - iVar5 < iVar4 ) )
2020-04-03 00:44:09 +02:00
return 1 ;
}
}
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
}
// decompiled code
// original method signature:
// int /*$ra*/ TannerCarCollisionCheck(struct VECTOR *pPos /*$s5*/, int dir /*$a1*/, int bQuick /*stack 8*/)
// line 3762, offset 0x00070a9c
/* begin block 1 */
// Start line: 3763
// Start offset: 0x00070A9C
// Variables:
// int carLength[2]; // stack offset -120
// struct _CAR_DATA *cp0; // $s0
// struct _CAR_DATA *cp1; // $s1
// static struct CRET2D collisionResult; // offset 0x30
// unsigned int dNewLBODY[2]; // stack offset -112
// int speed; // $v0
/* begin block 1.1 */
// Start line: 3798
// Start offset: 0x00070B2C
/* begin block 1.1.1 */
// Start line: 3798
// Start offset: 0x00070B2C
/* end block 1.1.1 */
// End offset: 0x00070B2C
// End Line: 3798
/* begin block 1.1.2 */
// Start line: 3815
// Start offset: 0x00070C04
// Variables:
// struct VECTOR velocity; // stack offset -104
// long pointVel[4]; // stack offset -88
// long reaction[4]; // stack offset -72
// long lever[4]; // stack offset -56
// int strikeVel; // $t1
/* begin block 1.1.2.1 */
// Start line: 3846
// Start offset: 0x00070D84
/* end block 1.1.2.1 */
// End offset: 0x00070D84
// End Line: 3857
/* begin block 1.1.2.2 */
// Start line: 3861
// Start offset: 0x00070DB0
// Variables:
// int twistY; // $a2
// int lever_dot_n; // $a0
// int displacementsquared; // $a1
// int denom; // $a0
/* end block 1.1.2.2 */
// End offset: 0x00070E8C
// End Line: 3874
/* end block 1.1.2 */
// End offset: 0x00070FD8
// End Line: 3895
/* end block 1.1 */
// End offset: 0x00071008
// End Line: 3904
/* end block 1 */
// End offset: 0x00071054
// End Line: 3907
/* begin block 2 */
// Start line: 8611
/* end block 2 */
// End Line: 8612
/* begin block 3 */
// Start line: 8621
/* end block 3 */
// End Line: 8622
/* begin block 4 */
// Start line: 8646
/* end block 4 */
// End Line: 8647
/* WARNING: Removing unreachable block (ram,0x00070ec8) */
/* WARNING: Type propagation algorithm not settling */
2020-05-24 10:36:48 +02:00
// [D]
2020-04-03 00:44:09 +02:00
int TannerCarCollisionCheck ( VECTOR * pPos , int dir , int bQuick )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
int iVar1 ;
uint uVar2 ;
int iVar3 ;
int iVar4 ;
int iVar5 ;
int iVar6 ;
int iVar7 ;
int iVar8 ;
int iVar9 ;
int iVar10 ;
int iVar11 ;
int iVar12 ;
2020-05-24 10:36:48 +02:00
_CAR_DATA * cp1 ;
int carLength ;
int dNewLBODY [ 2 ] ;
VECTOR velocity ;
long pointVel [ 4 ] ;
long reaction [ 4 ] ;
long lever [ 4 ] ;
static struct CRET2D collisionResult ; // offset 0x30
CDATA2D cd [ 2 ] ;
cd [ 0 ] . length [ 0 ] = 0x3c ;
cd [ 0 ] . length [ 1 ] = 0x3c ;
cd [ 0 ] . x . vx = pPos - > vx ;
cd [ 0 ] . x . vz = pPos - > vz ;
cp1 = car_data + 0x13 ;
cd [ 0 ] . theta = dir ;
2020-04-03 00:44:09 +02:00
do {
2020-05-24 10:36:48 +02:00
uVar2 = cp1 - > ap . model ;
cd [ 1 ] . x . vx = cp1 - > hd . where . t [ 0 ] ;
cd [ 1 ] . length [ 0 ] = car_cosmetics [ uVar2 ] . colBox . vz ;
cd [ 1 ] . length [ 1 ] = car_cosmetics [ uVar2 ] . colBox . vx ;
cd [ 1 ] . theta = cp1 - > hd . direction ;
cd [ 1 ] . x . vz = cp1 - > hd . where . t [ 2 ] ;
if ( cp1 - > controlType ! = 0 )
{
2020-05-24 11:07:53 +02:00
iVar3 = cp1 - > hd . where . t [ 1 ] + pPos - > vy ;
2020-05-24 10:36:48 +02:00
2020-04-03 00:44:09 +02:00
if ( iVar3 < 0 ) {
iVar3 = - iVar3 ;
}
2020-05-24 10:36:48 +02:00
if ( iVar3 < 500 & & bcollided2d ( cd , 1 ) ! = 0 )
{
if ( bQuick ! = 0 )
2020-04-03 00:44:09 +02:00
return 1 ;
2020-05-24 10:36:48 +02:00
2020-09-11 11:30:58 +02:00
if ( 50 < FIXEDH ( cp1 - > hd . wheel_speed ) )
2020-04-03 00:44:09 +02:00
return 1 ;
2020-05-24 10:36:48 +02:00
bFindCollisionPoint ( cd , & collisionResult ) ;
iVar3 = - collisionResult . surfNormal . vz ;
iVar1 = - collisionResult . surfNormal . vx ;
2020-09-11 11:30:58 +02:00
iVar10 = pcdTanner - > hd . where . t [ 2 ] + FIXEDH ( collisionResult . penetration * iVar3 ) ;
2020-05-24 10:36:48 +02:00
iVar12 = collisionResult . hit . vz - iVar10 ;
collisionResult . hit . vy = pcdTanner - > hd . where . t [ 1 ] + 0x3c ;
iVar9 = collisionResult . hit . vy - pcdTanner - > hd . where . t [ 1 ] ;
2020-09-11 11:30:58 +02:00
iVar8 = pcdTanner - > hd . where . t [ 0 ] + FIXEDH ( collisionResult . penetration * iVar1 ) ;
2020-05-24 10:36:48 +02:00
iVar11 = collisionResult . hit . vx - iVar8 ;
collisionResult . surfNormal . vy = 0 ;
2020-09-11 11:30:58 +02:00
iVar7 = FIXEDH ( pcdTanner - > st . n . angularVelocity [ 1 ] * iVar12 - pcdTanner - > st . n . angularVelocity [ 2 ] * iVar9 ) + pcdTanner - > st . n . linearVelocity [ 0 ] ;
iVar5 = FIXEDH ( pcdTanner - > st . n . angularVelocity [ 0 ] * iVar9 - pcdTanner - > st . n . angularVelocity [ 1 ] * iVar11 ) + pcdTanner - > st . n . linearVelocity [ 2 ] ;
2020-05-24 10:36:48 +02:00
2020-04-03 00:44:09 +02:00
iVar4 = iVar1 ;
iVar6 = iVar3 ;
2020-05-24 10:36:48 +02:00
2020-09-11 09:10:50 +02:00
iVar5 = FixFloorSigned ( iVar7 , 8 ) * FixFloorSigned ( iVar4 , 4 ) + FixFloorSigned ( iVar5 , 8 ) * FixFloorSigned ( iVar6 , 4 ) ;
2020-05-24 10:36:48 +02:00
if ( iVar5 < 0 )
{
2020-09-11 11:30:58 +02:00
iVar7 = FIXEDH ( iVar11 * iVar1 + iVar12 * iVar3 ) ;
iVar7 = FIXEDH ( ( ( iVar11 * iVar11 + iVar12 * iVar12 ) - iVar7 * iVar7 ) * car_cosmetics [ pcdTanner - > ap . model ] . twistRateY ) + 0x1000 ;
2020-05-24 10:36:48 +02:00
if ( - iVar5 < 0x7f001 )
2020-04-03 00:44:09 +02:00
iVar5 = ( iVar5 * - 0x1000 ) / iVar7 ;
2020-05-24 10:36:48 +02:00
else
2020-04-03 00:44:09 +02:00
iVar5 = - iVar5 / iVar7 < < 0xc ;
2020-05-24 10:36:48 +02:00
2020-04-03 00:44:09 +02:00
iVar7 = iVar1 ;
2020-05-24 10:36:48 +02:00
2020-09-11 09:10:50 +02:00
iVar4 = FixFloorSigned ( iVar5 , 6 ) * FixFloorSigned ( iVar7 , 6 ) ;
2020-04-03 00:44:09 +02:00
iVar7 = iVar3 ;
2020-05-24 10:36:48 +02:00
2020-09-11 09:10:50 +02:00
iVar5 = FixFloorSigned ( iVar5 , 6 ) * FixFloorSigned ( iVar7 , 6 ) ;
2020-05-24 10:36:48 +02:00
pcdTanner - > st . n . linearVelocity [ 0 ] = pcdTanner - > st . n . linearVelocity [ 0 ] + iVar4 ;
pcdTanner - > st . n . linearVelocity [ 2 ] = pcdTanner - > st . n . linearVelocity [ 2 ] + iVar5 ;
2020-09-11 11:30:58 +02:00
pcdTanner - > hd . aacc [ 2 ] = pcdTanner - > hd . aacc [ 2 ] - FIXEDH ( iVar9 * iVar4 ) ;
pcdTanner - > hd . aacc [ 0 ] = pcdTanner - > hd . aacc [ 0 ] + FIXEDH ( iVar9 * iVar5 ) ;
2020-05-24 10:36:48 +02:00
2020-09-11 11:30:58 +02:00
pcdTanner - > hd . aacc [ 1 ] = ( pcdTanner - > hd . aacc [ 1 ] + FIXEDH ( iVar12 * iVar4 ) ) - FIXEDH ( iVar11 * iVar5 ) ;
2020-05-24 10:36:48 +02:00
collisionResult . hit . vy = - collisionResult . hit . vy ;
2020-04-03 00:44:09 +02:00
}
2020-05-24 10:36:48 +02:00
2020-09-11 11:30:58 +02:00
pcdTanner - > hd . where . t [ 0 ] = iVar8 - FIXEDH ( pcdTanner - > st . n . linearVelocity [ 0 ] ) ;
pcdTanner - > hd . where . t [ 2 ] = iVar10 - FIXEDH ( pcdTanner - > st . n . linearVelocity [ 2 ] ) ;
2020-05-24 10:36:48 +02:00
collisionResult . surfNormal . vx = iVar1 ;
collisionResult . surfNormal . vz = iVar3 ;
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
}
// decompiled code
// original method signature:
// int /*$ra*/ PingOutPed(struct PEDESTRIAN *pPed /*$a2*/)
// line 3915, offset 0x000731f8
/* begin block 1 */
// Start line: 3916
// Start offset: 0x000731F8
// Variables:
// int px; // $a0
// int pz; // $v1
// int ps; // $a0
/* end block 1 */
// End offset: 0x00073270
// End Line: 3938
/* begin block 2 */
// Start line: 23590
/* end block 2 */
// End Line: 23591
/* begin block 3 */
// Start line: 24071
/* end block 3 */
// End Line: 24072
2020-05-15 12:33:29 +02:00
// [D]
2020-03-27 21:47:29 +01:00
int PingOutPed ( PEDESTRIAN * pPed )
{
2020-05-15 12:33:29 +02:00
int pz ;
int px ;
int ps ;
px = ( pPed - > position ) . vx - player [ 0 ] . pos [ 0 ] ;
pz = ( pPed - > position ) . vz - player [ 0 ] . pos [ 2 ] ;
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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupCivJump(struct PEDESTRIAN *pPed /*$s1*/, struct _CAR_DATA *cp /*$s0*/)
// line 3946, offset 0x00071054
/* begin block 1 */
// Start line: 3947
// Start offset: 0x00071054
// Variables:
// long disp[4]; // stack offset -48
// long dir[4]; // stack offset -32
// int angle; // $s0
/* begin block 1.1 */
// Start line: 3960
// Start offset: 0x000710C0
// Variables:
// short scale; // $a2
/* end block 1.1 */
// End offset: 0x000710E4
// End Line: 3967
/* begin block 1.2 */
// Start line: 4008
// Start offset: 0x000711E8
/* end block 1.2 */
// End offset: 0x000712AC
// End Line: 4027
/* end block 1 */
// End offset: 0x00071324
// End Line: 4040
/* begin block 2 */
// Start line: 9290
/* end block 2 */
// End Line: 9291
/* begin block 3 */
// Start line: 9330
/* end block 3 */
// End Line: 9331
2020-05-15 12:33:29 +02:00
// [D]
2020-04-03 00:44:09 +02:00
void SetupCivJump ( PEDESTRIAN * pPed , _CAR_DATA * cp )
2020-03-27 21:47:29 +01:00
{
2020-05-15 12:33:29 +02:00
int iVar1 ;
long lVar2 ;
int y ;
2020-04-03 00:44:09 +02:00
int iVar3 ;
2020-05-15 12:33:29 +02:00
short scale ;
int x ;
ushort uVar4 ;
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 ] )
{
2020-04-03 00:44:09 +02:00
scale = 0x1000 ;
2020-05-15 12:33:29 +02:00
if ( player [ 0 ] . horn . on ! = 0 )
2020-04-03 00:44:09 +02:00
scale = 0x800 ;
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 ;
pPed - > flags = pPed - > flags | 0x10 ;
2020-05-15 12:33:29 +02:00
pPed - > fpAgitatedState = CivPedJump ;
2020-04-03 00:44:09 +02:00
SetupPedMotionData ( pPed ) ;
2020-05-15 12:33:29 +02:00
if ( cp = = NULL )
{
if ( bAvoidTanner = = 0 )
{
lVar2 = ratan2 ( pPed - > position . vx - explosion [ bAvoidBomb ] . pos . vx , pPed - > position . vz - explosion [ bAvoidBomb ] . pos . vz ) ;
uVar4 = lVar2 - 0x800 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:33:29 +02:00
else
{
2020-04-03 00:44:09 +02:00
scale = 0x400 ;
2020-05-15 12:33:29 +02:00
// [A] fuck....
2020-06-21 03:12:38 +02:00
if ( FIXED ( - ( ( int ) ( player [ 0 ] . pPed ) - > speed * ( int ) rcossin_tbl [ ( ( int ) ( ( player [ 0 ] . pPed ) - > dir ) . vy - 0x800U & 0xfff ) * 2 + 1 ] ) ) *
( ( ( player [ 0 ] . pPed ) - > position ) . vx - ( pPed - > position ) . vx ) +
FIXED ( ( int ) ( player [ 0 ] . pPed ) - > speed * ( int ) rcossin_tbl [ ( ( int ) ( ( player [ 0 ] . pPed ) - > dir ) . vy - 0x800U & 0xfff ) * 2 ] ) *
( ( ( player [ 0 ] . pPed ) - > position ) . vz - ( pPed - > position ) . vz ) + 0x800 < 0 )
2020-05-15 12:33:29 +02:00
{
2020-04-03 00:44:09 +02:00
scale = - 0x400 ;
}
2020-05-15 12:33:29 +02:00
uVar4 = scale + ( ( player [ 0 ] . pPed ) - > dir ) . vy ;
2020-04-03 00:44:09 +02:00
}
}
2020-05-15 12:33:29 +02:00
else
{
x = ( cp - > hd ) . where . t [ 0 ] - ( pPed - > position ) . vx ;
iVar3 = ( cp - > st ) . n . linearVelocity [ 2 ] ;
y = ( cp - > hd ) . where . t [ 2 ] - ( pPed - > position ) . vz ;
iVar1 = - ( cp - > st ) . n . linearVelocity [ 0 ] ;
if ( ( iVar3 = = 0 ) & & ( iVar1 = = 0 ) )
{
lVar2 = ratan2 ( y , x ) ;
uVar4 = lVar2 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:33:29 +02:00
else
{
lVar2 = ratan2 ( ( cp - > st ) . n . linearVelocity [ 2 ] , ( cp - > st ) . n . linearVelocity [ 0 ] ) ;
uVar4 = ( ( short ) ~ ( ushort ) ( iVar3 * x + iVar1 * y + 0x800 > > 0x1c ) > > 0xf & 0x800U ) - lVar2 ;
2020-04-03 00:44:09 +02:00
}
}
2020-05-15 12:33:29 +02:00
2020-06-22 19:50:29 +02:00
pPed - > dir . vy = uVar4 & 0xfff ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CivPedJump(struct PEDESTRIAN *pPed /*$s0*/)
// line 4047, offset 0x00072cf0
/* begin block 1 */
// Start line: 4048
// Start offset: 0x00072CF0
/* end block 1 */
// End offset: 0x00072DA0
// End Line: 4073
/* begin block 2 */
// Start line: 20349
/* end block 2 */
// End Line: 20350
/* begin block 3 */
// Start line: 8094
/* end block 3 */
// End Line: 8095
2020-05-15 12:33:29 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void CivPedJump ( PEDESTRIAN * pPed )
{
2020-05-15 12:33:29 +02:00
if ( pPed - > frame1 = = 2 )
2020-04-03 00:44:09 +02:00
pPed - > speed = pPed - > speed < < 1 ;
2020-05-15 12:33:29 +02:00
else if ( pPed - > frame1 = = 14 )
2020-04-03 00:44:09 +02:00
pPed - > speed = pPed - > speed > > 1 ;
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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupCivPedWalk(struct PEDESTRIAN *pPed /*$s0*/)
// line 4080, offset 0x00073270
/* begin block 1 */
// Start line: 24276
/* end block 1 */
// End Line: 24277
/* begin block 2 */
// Start line: 24419
/* end block 2 */
// End Line: 24420
2020-05-15 12:33:29 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupCivPedWalk ( PEDESTRIAN * pPed )
{
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-05-15 12:33:29 +02:00
pPed - > frame1 = 0 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CivPedWalk(struct PEDESTRIAN *pPed /*$s0*/)
// line 4101, offset 0x00071324
/* begin block 1 */
// Start line: 4102
// Start offset: 0x00071324
// Variables:
// int turn; // $a1
// int offset1; // $t0
// int offset2; // $v1
// int lookahead; // $s3
// int speed; // $s1
/* end block 1 */
// End offset: 0x000715FC
// End Line: 4182
/* begin block 2 */
// Start line: 9615
/* end block 2 */
// End Line: 9616
/* begin block 3 */
// Start line: 9677
/* end block 3 */
// End Line: 9678
2020-05-15 12:33:29 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void CivPedWalk ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
short sVar2 ;
ushort uVar3 ;
uint uVar4 ;
int turn ;
int iVar5 ;
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
iVar5 = pPed - > speed ;
if ( ( * ( uint * ) & pPed - > speed & 0xffff00 ) = = 0x90000 )
{
sVar2 = pPed - > dir . vy ;
uVar4 = pPed - > dir . vy + 2048 ;
2020-04-03 00:44:09 +02:00
}
else {
2020-05-15 12:33:29 +02:00
sVar2 = pPed - > dir . vy ;
uVar4 = pPed - > dir . vy + 1850 ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:33:29 +02:00
if ( ( pPed - > flags & 2U ) = = 0 )
{
2020-04-03 00:44:09 +02:00
turn = IsPavement ( ( pPed - > position ) . vx + ( ( int ) rcossin_tbl [ ( uVar4 & 0xfff ) * 2 ] > > 5 ) ,
( pPed - > position ) . vy ,
( pPed - > position ) . vz + ( ( int ) rcossin_tbl [ ( uVar4 & 0xfff ) * 2 + 1 ] > > 5 ) , pPed ) ;
2020-05-15 12:33:29 +02:00
if ( turn = = 0 )
{
2020-06-21 03:12:38 +02:00
if ( ( * ( uint * ) & pPed - > speed & 0xffff00 ) = = 0x90000 )
{
2020-06-22 19:50:29 +02:00
uVar4 = ( int ) pPed - > dir . vy + 0xa00U & 0xfff ;
2020-06-21 03:12:38 +02:00
turn = IsPavement (
( pPed - > position ) . vx + FIXED ( rcossin_tbl [ uVar4 * 2 ] * 0x80 ) ,
2020-04-03 00:44:09 +02:00
( pPed - > position ) . vy ,
2020-06-21 03:12:38 +02:00
( pPed - > position ) . vz + FIXED ( rcossin_tbl [ uVar4 * 2 + 1 ] * 0x80 ) ,
2020-04-03 00:44:09 +02:00
( PEDESTRIAN * ) 0x0 ) ;
2020-05-15 12:33:29 +02:00
if ( turn = = 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
turn = - 128 ;
if ( ( pPed - > flags & 0x2000U ) ! = 0 )
turn = 128 ;
if ( pPed - > doing_turn < 32 )
{
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-05-15 12:33:29 +02:00
else
{
uVar4 = pPed - > dir . vy + 0x800U & 0xfff ;
2020-06-21 03:12:38 +02:00
pPed - > velocity . vx = FIXED ( iVar5 * rcossin_tbl [ uVar4 * 2 ] ) ;
pPed - > velocity . vz = FIXED ( iVar5 * rcossin_tbl [ uVar4 * 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 )
{
uVar3 = pPed - > dir . vy + 0x200U & 0xfc00 ;
pPed - > dir . vy = uVar3 ;
2020-06-21 03:12:38 +02:00
uVar4 = uVar3 + 0x800U & 0xfff ;
pPed - > velocity . vx = FIXED ( iVar5 * rcossin_tbl [ uVar4 * 2 ] ) ;
2020-04-03 00:44:09 +02:00
sVar2 = rcossin_tbl [ uVar4 * 2 + 1 ] ;
2020-05-15 12:33:29 +02:00
pPed - > finished_turn = 9 ;
2020-06-21 03:12:38 +02:00
pPed - > velocity . vz = FIXED ( iVar5 * sVar2 ) ;
2020-04-03 00:44:09 +02:00
}
}
}
2020-05-15 12:33:29 +02:00
else
{
pPed - > speed = 0 ;
pPed - > dir . vy = sVar2 + 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
}
// decompiled code
// original method signature:
// void /*$ra*/ CivPedSit(struct PEDESTRIAN *pPed /*$a0*/)
// line 4190, offset 0x00072ce8
/* begin block 1 */
// Start line: 4192
// Start offset: 0x00072CE8
/* end block 1 */
// End offset: 0x00072CF0
// End Line: 4208
/* begin block 2 */
// Start line: 20475
/* end block 2 */
// End Line: 20476
/* begin block 3 */
// Start line: 20476
/* end block 3 */
// End Line: 20477
/* begin block 4 */
// Start line: 20480
/* end block 4 */
// End Line: 20481
2020-04-03 00:44:09 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void CivPedSit ( PEDESTRIAN * pPed )
{
2020-05-15 12:33:29 +02:00
pPed - > frame1 = 0 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ HandlePedestrians()
// line 4221, offset 0x0007211c
/* begin block 1 */
// Start line: 4223
// Start offset: 0x0007211C
/* end block 1 */
// End offset: 0x0007215C
// End Line: 4457
/* begin block 2 */
// Start line: 13906
/* end block 2 */
// End Line: 13907
/* begin block 3 */
// Start line: 13907
/* end block 3 */
// End Line: 13908
/* begin block 4 */
// Start line: 13925
/* end block 4 */
// End Line: 13926
/* WARNING: Unknown calling convention yet parameter storage is locked */
void HandlePedestrians ( void )
{
2020-05-15 12:33:29 +02:00
if ( gInGameCutsceneActive = = 0 & & NumPlayers = = 1 )
{
2020-04-03 00:44:09 +02:00
BuildCarCollisionBox ( ) ;
ControlPedestrians ( ) ;
PingInPedestrians ( ) ;
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ PedestrianActionInit_WalkToTarget(struct PEDESTRIAN *pPed /*$s0*/)
// line 4465, offset 0x0007283c
/* begin block 1 */
// Start line: 4466
// Start offset: 0x0007283C
// Variables:
// int dir; // $v1
/* end block 1 */
// End offset: 0x000728B8
// End Line: 4496
/* begin block 2 */
// Start line: 18892
/* end block 2 */
// End Line: 18893
/* begin block 3 */
// Start line: 8930
/* end block 3 */
// End Line: 8931
2020-05-15 12:33:29 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void PedestrianActionInit_WalkToTarget ( PEDESTRIAN * pPed )
{
2020-05-15 12:33:29 +02:00
int dir ;
dir = CalcPedestrianDirection ( 0 , ( pPed - > position ) . vx , ( pPed - > position ) . vz , & pPed - > target ) ;
if ( dir ! = 0 )
{
pPed - > last_dir = dir ;
if ( dir = = 1 )
pPed - > dir . vy = 0x400 ;
else if ( dir = = 2 )
pPed - > dir . vy = 0xc00 ;
else if ( dir = = 4 )
pPed - > dir . vy = 0 ;
else if ( dir = = 8 )
pPed - > dir . vy = 0x800 ;
2020-04-03 00:44:09 +02:00
CorrectPathPosition ( pPed , ( VECTOR * ) & pPed - > position ) ;
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CorrectPathPosition(struct PEDESTRIAN *pedestrian /*$a0*/, struct VECTOR *position /*$a1*/)
// line 4508, offset 0x000715fc
/* begin block 1 */
// Start line: 4510
// Start offset: 0x000715FC
// Variables:
// struct VECTOR vec; // stack offset -16
/* end block 1 */
// End offset: 0x000715FC
// End Line: 4610
/* begin block 2 */
// Start line: 10180
/* end block 2 */
// End Line: 10181
/* begin block 3 */
// Start line: 10507
/* end block 3 */
// End Line: 10508
/* begin block 4 */
// Start line: 10508
/* end block 4 */
// End Line: 10509
/* begin block 5 */
// Start line: 10608
/* end block 5 */
// End Line: 10609
2020-04-03 00:44:09 +02:00
// [D]
void CorrectPathPosition ( PEDESTRIAN * pedestrian , VECTOR * position )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
return ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// int /*$ra*/ CalcPedestrianDirection(int last_dir /*$a0*/, int wx /*$s5*/, int wz /*$s6*/, struct VECTOR *target /*$s3*/)
// line 4619, offset 0x00071608
/* begin block 1 */
// Start line: 4620
// Start offset: 0x00071608
// Variables:
// int dir; // $s2
// int num; // $s1
// int rx; // $v1
// int rz; // $a0
// int mask; // $s0
/* begin block 1.1 */
// Start line: 4669
// Start offset: 0x000716C0
/* end block 1.1 */
// End offset: 0x0007170C
// End Line: 4681
/* end block 1 */
// End offset: 0x000717AC
// End Line: 4734
/* begin block 2 */
// Start line: 10729
/* end block 2 */
// End Line: 10730
/* begin block 3 */
// Start line: 10737
/* end block 3 */
// End Line: 10738
2020-05-15 12:41:49 +02:00
// [D]
2020-04-03 00:44:09 +02:00
int CalcPedestrianDirection ( int last_dir , int wx , int wz , VECTOR * target )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
long lVar1 ;
int iVar2 ;
uint uVar3 ;
uint uVar4 ;
uint uVar5 ;
2020-05-15 12:41:49 +02:00
uVar5 = pedestrian_roads . west = = - 20 ;
uVar4 = pedestrian_roads . west = = - 20 ;
if ( pedestrian_roads . east = = - 20 )
{
2020-04-03 00:44:09 +02:00
uVar5 = uVar5 | 2 ;
2020-05-15 12:41:49 +02:00
uVar4 + + ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:41:49 +02:00
if ( pedestrian_roads . north = = - 20 )
{
2020-04-03 00:44:09 +02:00
uVar5 = uVar5 | 4 ;
2020-05-15 12:41:49 +02:00
uVar4 + + ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:41:49 +02:00
if ( pedestrian_roads . south = = - 20 )
{
2020-04-03 00:44:09 +02:00
uVar5 = uVar5 | 8 ;
2020-05-15 12:41:49 +02:00
uVar4 + + ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:41:49 +02:00
2020-04-03 00:44:09 +02:00
uVar3 = uVar5 & last_dir ;
2020-05-15 12:41:49 +02:00
if ( ( uVar3 = = 0 ) & & ( uVar3 = uVar5 , 1 < uVar4 ) )
{
2020-04-03 00:44:09 +02:00
lVar1 = Random2 ( 0 ) ;
uVar3 = 0x10 ;
2020-05-15 12:41:49 +02:00
if ( uVar4 = = 0 )
2020-04-03 00:44:09 +02:00
trap ( 7 ) ;
2020-05-15 12:41:49 +02:00
2020-04-03 00:44:09 +02:00
iVar2 = lVar1 % uVar4 + 1 ;
2020-05-15 12:41:49 +02:00
while ( iVar2 ! = 0 )
{
2020-04-03 00:44:09 +02:00
uVar3 = ( int ) uVar3 > > 1 ;
2020-05-15 12:41:49 +02:00
if ( ( uVar5 & uVar3 ) ! = 0 )
iVar2 - - ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:41:49 +02:00
2020-04-03 00:44:09 +02:00
uVar3 = uVar5 & uVar3 ;
}
2020-05-15 12:41:49 +02:00
2020-04-03 00:44:09 +02:00
uVar4 = wx & 0xfffffc00 ;
uVar5 = wz & 0xfffffc00 ;
2020-05-15 12:41:49 +02:00
if ( uVar3 = = 2 )
{
2020-04-03 00:44:09 +02:00
iVar2 = uVar4 + 0x600 ;
}
2020-05-15 12:41:49 +02:00
else
{
if ( 2 < uVar3 )
{
if ( uVar3 = = 4 )
{
2020-04-03 00:44:09 +02:00
iVar2 = uVar5 + 0x600 ;
}
2020-05-15 12:41:49 +02:00
else
{
2020-04-03 00:44:09 +02:00
iVar2 = uVar5 - 0x200 ;
2020-05-15 12:41:49 +02:00
if ( uVar3 ! = 8 )
goto LAB_0007177c ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:41:49 +02:00
2020-04-03 00:44:09 +02:00
target - > vx = uVar4 + 0x200 ;
target - > vz = iVar2 ;
2020-05-15 12:41:49 +02:00
2020-04-03 00:44:09 +02:00
goto LAB_0007177c ;
}
iVar2 = uVar4 - 0x200 ;
2020-05-15 12:41:49 +02:00
if ( uVar3 ! = 1 )
goto LAB_0007177c ;
2020-04-03 00:44:09 +02:00
}
target - > vx = iVar2 ;
target - > vz = uVar5 + 0x200 ;
2020-03-27 21:47:29 +01:00
LAB_0007177c :
2020-04-03 00:44:09 +02:00
target - > vy = 0 ;
2020-05-15 12:41:49 +02:00
return uVar3 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// int /*$ra*/ IsPavement(int x /*$a0*/, int y /*$a1*/, int z /*$a2*/, struct PEDESTRIAN *pPed /*$s0*/)
// line 4845, offset 0x000725b8
/* begin block 1 */
// Start line: 4846
// Start offset: 0x000725B8
// Variables:
// struct VECTOR vec; // stack offset -24
// int r; // $v1
/* end block 1 */
// End offset: 0x00072644
// End Line: 4917
/* begin block 2 */
// Start line: 18844
/* end block 2 */
// End Line: 18845
/* begin block 3 */
// Start line: 9690
/* end block 3 */
// End Line: 9691
/* begin block 4 */
// Start line: 18854
/* end block 4 */
// End Line: 18855
2020-05-15 12:41:49 +02:00
// [D] [A] might be incorrect
2020-04-03 00:44:09 +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 ) ;
if ( r = = - 20 )
{
return ( RoadInCell ( & v ) ! = 0 ) ;
2020-04-03 00:44:09 +02:00
}
2020-05-15 12:41:49 +02:00
else if ( pPed )
{
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
}
// decompiled code
// original method signature:
// void /*$ra*/ SetPedestrianTurn(struct PEDESTRIAN *pedestrian /*$a0*/, int turn /*$a1*/)
// line 4924, offset 0x00072500
/* begin block 1 */
// Start line: 4925
// Start offset: 0x00072500
// Variables:
// int dir; // $a2
// int speed; // $v1
/* end block 1 */
// End offset: 0x00072584
// End Line: 4935
/* begin block 2 */
// Start line: 15021
/* end block 2 */
// End Line: 15022
/* begin block 3 */
// Start line: 18487
/* end block 3 */
// End Line: 18488
/* begin block 4 */
// Start line: 18488
/* end block 4 */
// End Line: 18489
2020-05-15 12:41:49 +02:00
// [D]
2020-04-03 00:44:09 +02:00
void SetPedestrianTurn ( PEDESTRIAN * pedestrian , int turn )
2020-03-27 21:47:29 +01:00
{
2020-09-11 11:30:58 +02:00
int uVar6 ;
2020-05-15 12:41:49 +02:00
2020-09-11 11:30:58 +02:00
pedestrian - > dir . vy = pedestrian - > dir . vy + turn & 0xfff ;
2020-05-15 12:41:49 +02:00
2020-04-03 00:44:09 +02:00
uVar6 = uVar6 + 0x800 & 0xfff ;
2020-05-15 12:41:49 +02:00
2020-09-11 11:30:58 +02:00
pedestrian - > position . vz = pedestrian - > position . vz - pedestrian - > velocity . vz ;
pedestrian - > position . vx = pedestrian - > position . vx - pedestrian - > velocity . vx ;
2020-05-15 12:41:49 +02:00
2020-09-11 11:30:58 +02:00
pedestrian - > velocity . vx = FIXED ( pedestrian - > speed * rcossin_tbl [ uVar6 * 2 ] ) ;
pedestrian - > velocity . vz = FIXED ( pedestrian - > speed * rcossin_tbl [ uVar6 * 2 + 1 ] ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// struct SEATED_PEDESTRIANS * /*$ra*/ FindSeated()
// line 4943, offset 0x00072644
/* begin block 1 */
// Start line: 4945
// Start offset: 0x00072644
// Variables:
// struct SEATED_PEDESTRIANS *seatedptr; // $s0
/* begin block 1.1 */
// Start line: 4950
// Start offset: 0x0007266C
// Variables:
// int dx; // $v1
// int dz; // $v0
// int distsqr; // $v1
// int count1; // $a2
/* end block 1.1 */
// End offset: 0x00072724
// End Line: 4975
/* end block 1 */
// End offset: 0x00072738
// End Line: 4977
/* begin block 2 */
// Start line: 19027
/* end block 2 */
// End Line: 19028
/* begin block 3 */
// Start line: 19054
/* end block 3 */
// End Line: 19055
/* begin block 4 */
// Start line: 19055
/* end block 4 */
// End Line: 19056
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-05-15 12:41:49 +02:00
// [D]
2020-03-27 21:47:29 +01:00
SEATED_PEDESTRIANS * FindSeated ( void )
{
2020-04-03 00:44:09 +02:00
int iVar1 ;
int iVar2 ;
int iVar3 ;
SEATED_PEDESTRIANS * seatedptr ;
2020-05-15 12:41:49 +02:00
if ( seated_pedestrian )
{
if ( seated_pedestrian - > rotation = = 9999 )
return NULL ;
2020-04-03 00:44:09 +02:00
iVar3 = 3 ;
2020-05-15 12:41:49 +02:00
2020-04-03 00:44:09 +02:00
do {
seatedptr = seated_pedestrian + seated_count ;
2020-06-28 23:03:07 +02:00
seated_count + + ;
2020-05-15 12:41:49 +02:00
2020-06-28 23:03:07 +02:00
if ( seatedptr - > rotation = = 9999 )
2020-05-15 12:41:49 +02:00
{
2020-04-03 00:44:09 +02:00
seated_count = 0 ;
seatedptr = seated_pedestrian ;
}
2020-05-15 12:41:49 +02:00
if ( seatedptr - > index = = 0 & &
2020-06-21 03:12:38 +02:00
( iVar2 = FIXED ( seatedptr - > x - player [ 0 ] . pos [ 0 ] ) , iVar1 = FIXED ( seatedptr - > z - player [ 0 ] . pos [ 2 ] ) ,
iVar3 = iVar3 + - 1 , ( iVar2 * iVar2 + iVar1 * iVar1 ) - 0xbU < 0x1d ) )
2020-05-15 12:41:49 +02:00
{
2020-04-03 00:44:09 +02:00
add_seated ( seatedptr , seated_count ) ;
return seatedptr ;
}
2020-05-15 12:41:49 +02:00
2020-04-03 00:44:09 +02:00
} while ( iVar3 ! = 0 ) ;
}
2020-05-15 12:41:49 +02:00
return NULL ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// struct SEATED_PEDESTRIANS * /*$ra*/ FindTannerASeat(struct PEDESTRIAN *pPed /*$t4*/)
// line 4984, offset 0x000717ac
/* begin block 1 */
// Start line: 4985
// Start offset: 0x000717AC
// Variables:
// struct SEATED_PEDESTRIANS *seatedptr; // $a2
// struct SEATED_PEDESTRIANS *theOne; // $t1
// int dx; // $a0
// int dz; // $v1
// int distsqr; // $v0
// int bestSqr; // $t2
/* end block 1 */
// End offset: 0x000718C8
// End Line: 5023
/* begin block 2 */
// Start line: 11491
/* end block 2 */
// End Line: 11492
/* begin block 3 */
// Start line: 11493
/* end block 3 */
// End Line: 11494
2020-05-15 12:54:05 +02:00
// [D]
2020-03-27 21:47:29 +01:00
SEATED_PEDESTRIANS * FindTannerASeat ( PEDESTRIAN * pPed )
{
2020-04-03 00:44:09 +02:00
int iVar1 ;
int iVar2 ;
2020-05-15 12:54:05 +02:00
SEATED_PEDESTRIANS * seatedptr ;
SEATED_PEDESTRIANS * theOne ;
2020-04-03 00:44:09 +02:00
int iVar5 ;
2020-05-15 12:54:05 +02:00
theOne = NULL ;
2020-04-03 00:44:09 +02:00
iVar5 = 0x1000 ;
seated_count = 0 ;
2020-05-15 12:54:05 +02:00
if ( seated_pedestrian - > rotation ! = 9999 )
{
seatedptr = seated_pedestrian ;
2020-04-03 00:44:09 +02:00
seated_count = 0 ;
iVar1 = 0 ;
do {
2020-06-22 19:50:29 +02:00
iVar1 = seatedptr - > x - pPed - > position . vx ;
2020-05-15 12:54:05 +02:00
seated_count + + ;
if ( iVar1 < 0 )
2020-06-22 19:50:29 +02:00
iVar1 = pPed - > position . vx - seatedptr - > x ;
2020-05-15 12:54:05 +02:00
2020-06-22 19:50:29 +02:00
iVar2 = seatedptr - > z - pPed - > position . vz ;
2020-05-15 12:54:05 +02:00
if ( iVar2 < 0 )
2020-06-22 19:50:29 +02:00
iVar2 = pPed - > position . vz - seatedptr - > z ;
2020-05-15 12:54:05 +02:00
2020-09-27 11:03:11 +02:00
if ( ( ( iVar1 < 900 ) & & ( iVar2 < 900 ) ) & &
2020-06-21 03:12:38 +02:00
( iVar1 = FIXED ( iVar1 * iVar1 + iVar2 * iVar2 ) , iVar1 < iVar5 ) )
2020-05-15 12:54:05 +02:00
{
theOne = seatedptr ;
2020-04-03 00:44:09 +02:00
iVar5 = iVar1 ;
}
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
if ( iVar5 < 6 & & theOne )
{
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
}
// decompiled code
// original method signature:
// void /*$ra*/ add_seated(struct SEATED_PEDESTRIANS *seatedptr /*$s0*/, int seat_index /*$s2*/)
// line 5031, offset 0x000718c8
/* begin block 1 */
// Start line: 5032
// Start offset: 0x000718C8
// Variables:
// struct PEDESTRIAN *pedestrian; // $s1
// int index; // $v0
/* end block 1 */
// End offset: 0x00071A44
// End Line: 5076
/* begin block 2 */
// Start line: 11581
/* end block 2 */
// End Line: 11582
/* begin block 3 */
// Start line: 11590
/* end block 3 */
// End Line: 11591
/* begin block 4 */
// Start line: 11596
/* end block 4 */
// End Line: 11597
2020-05-15 12:54:05 +02:00
// [D]
2020-04-03 00:44:09 +02:00
void add_seated ( SEATED_PEDESTRIANS * seatedptr , int seat_index )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
PEDESTRIAN * pedptr ;
long lVar3 ;
long lVar4 ;
2020-05-15 12:54:05 +02:00
if ( num_pedestrians < 20 )
{
pedptr = CreatePedestrian ( ) ;
if ( ! pedptr )
return ;
seatedptr - > index = 2 ;
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 ] ;
pedptr - > position . vy = - 75 - MapHeight ( ( VECTOR * ) & pedptr - > position ) ;
2020-04-03 00:44:09 +02:00
pedptr - > index = 1 ;
pedptr - > seat_index = ( char ) seat_index ;
pedptr - > pedType = CIVILIAN ;
SetupPedestrian ( pedptr ) ;
2020-05-15 12:54:05 +02:00
pedptr - > fpAgitatedState = NULL ;
pedptr - > fpRestState = CivPedSit ;
2020-04-03 00:44:09 +02:00
lVar3 = Random2 ( 0 ) ;
lVar4 = Random2 ( 0 ) ;
2020-05-15 12:54:05 +02:00
pedptr - > pallet = lVar3 + ( lVar3 / 5 ) * - 5 + ( lVar4 + ( lVar4 / 5 ) * - 5 ) * 16 ;
2020-04-03 00:44:09 +02:00
lVar3 = Random2 ( 0 ) ;
2020-05-15 12:54:05 +02:00
if ( ( lVar3 / 6 ) * 6 = = lVar3 - 3 )
pedptr - > flags | = 0x4000 ;
2020-04-03 00:44:09 +02:00
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ set_coll_box(int index /*$t2*/, struct _CAR_DATA *cp /*$t0*/, int offset /*$t3*/)
// line 5084, offset 0x00071a5c
/* begin block 1 */
// Start line: 5085
// Start offset: 0x00071A5C
// Variables:
// struct VECTOR BoxCentre; // stack offset -16
// int boxsize; // $t1
/* end block 1 */
// End offset: 0x00071B74
// End Line: 5110
/* begin block 2 */
// Start line: 11714
/* end block 2 */
// End Line: 11715
2020-07-05 18:32:12 +02:00
CAR_COLLISION_BOX collision_box [ 8 ] ;
_CAR_DATA * collision_car_ptr [ 8 ] ;
// [D]
2020-04-03 00:44:09 +02:00
void set_coll_box ( int index , _CAR_DATA * cp , int offset )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
int iVar1 ;
int iVar2 ;
int iVar3 ;
int iVar4 ;
int iVar5 ;
2020-07-05 18:32:12 +02:00
VECTOR BoxCentre ;
2020-04-03 00:44:09 +02:00
2020-07-05 18:32:12 +02:00
if ( 8 < index )
2020-04-03 00:44:09 +02:00
return ;
2020-07-05 18:32:12 +02:00
2020-04-03 00:44:09 +02:00
iVar5 = 400 ;
2020-07-05 18:32:12 +02:00
if ( player [ 0 ] . horn . on ! = 0 )
{
iVar5 = 260 ;
if ( cp ! = & car_data [ player [ 0 ] . playerCarId ] )
goto LAB_00071b00 ;
iVar5 = 1200 ;
2020-04-03 00:44:09 +02:00
}
2020-07-05 18:32:12 +02:00
if ( cp ! = car_data + player [ 0 ] . playerCarId )
iVar5 = iVar5 - 140 ;
2020-03-27 21:47:29 +01:00
LAB_00071b00 :
2020-07-05 18:32:12 +02:00
iVar1 = cp - > st . n . linearVelocity [ 0 ] ;
iVar2 = cp - > hd . where . t [ 0 ] ;
iVar4 = cp - > st . n . linearVelocity [ 2 ] ;
iVar3 = cp - > hd . where . t [ 2 ] ;
collision_car_ptr [ index ] = cp ;
2020-04-03 00:44:09 +02:00
iVar2 = iVar2 + ( iVar1 > > ( offset & 0x1fU ) ) ;
iVar3 = iVar3 + ( iVar4 > > ( offset & 0x1fU ) ) ;
2020-07-05 18:32:12 +02:00
collision_box [ index ] . min_x = iVar2 - iVar5 ;
collision_box [ index ] . min_z = iVar3 - iVar5 ;
collision_box [ index ] . max_x = iVar2 + iVar5 ;
collision_box [ index ] . max_z = iVar3 + iVar5 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ BuildCarCollisionBox()
// line 5118, offset 0x00071b7c
/* begin block 1 */
// Start line: 5120
// Start offset: 0x00071B7C
// Variables:
// struct _CAR_DATA *cp; // $s3
// int count1; // $s4
// int i; // $t1
/* begin block 1.1 */
// Start line: 5146
// Start offset: 0x00071CBC
// Variables:
// int x; // $a0
// int z; // $a2
/* end block 1.1 */
// End offset: 0x00071D58
// End Line: 5155
/* end block 1 */
// End offset: 0x00071E0C
// End Line: 5171
/* begin block 2 */
// Start line: 11805
/* end block 2 */
// End Line: 11806
/* begin block 3 */
// Start line: 11806
/* end block 3 */
// End Line: 11807
/* begin block 4 */
// Start line: 11808
/* end block 4 */
// End Line: 11809
/* WARNING: Unknown calling convention yet parameter storage is locked */
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 ;
// [D]
2020-03-27 21:47:29 +01:00
void BuildCarCollisionBox ( void )
{
2020-04-03 00:44:09 +02:00
CAR_COLLISION_BOX * pCVar1 ;
CAR_COLLISION_BOX * pCVar2 ;
uint uVar3 ;
int iVar4 ;
int index ;
_ExOBJECT * p_Var5 ;
_CAR_DATA * cp ;
2020-07-05 18:32:12 +02:00
iVar4 = ( int ) player [ 0 ] . playerCarId ;
2020-08-11 16:39:40 +02:00
if ( iVar4 ! = - 1 ) // [A] ASan bug fix
{
set_coll_box ( 0 , car_data + iVar4 , 8 ) ;
set_coll_box ( 1 , car_data + iVar4 , 9 ) ;
}
2020-04-03 00:44:09 +02:00
iVar4 = 2 ;
cp = car_data + ( CameraCnt & 3 ) ;
index = iVar4 ;
2020-07-05 18:32:12 +02:00
if ( cp < car_data + 20 )
{
2020-04-03 00:44:09 +02:00
do {
iVar4 = index ;
2020-07-05 18:32:12 +02:00
if ( cp ! = & car_data [ player [ 0 ] . playerCarId ] & & cp - > controlType ! = 0 )
{
2020-04-03 00:44:09 +02:00
iVar4 = index + 1 ;
set_coll_box ( index , cp , 8 ) ;
}
2020-07-05 18:32:12 +02:00
2020-08-11 16:39:40 +02:00
cp = cp + 4 ; // [A] WTF?
2020-04-03 00:44:09 +02:00
index = iVar4 ;
2020-07-05 18:32:12 +02:00
} while ( cp < car_data + 20 ) ;
2020-04-03 00:44:09 +02:00
}
2020-07-05 18:32:12 +02:00
if ( player [ 0 ] . playerType = = 2 )
{
uVar3 = ( int ) player [ 0 ] . pPed - > dir . vy - 0x800U & 0xfff ;
index = FIXED ( player [ 0 ] . pPed - > speed * ( int ) rcossin_tbl [ uVar3 * 2 ] * 4 ) ;
tanner_collision_box . min_x = ( ( player [ 0 ] . pPed ) - > position ) . vx + index + - 148 ;
tanner_collision_box . max_x = ( ( player [ 0 ] . pPed ) - > position ) . vx + index + 148 ;
index = FIXED ( player [ 0 ] . pPed - > speed * ( int ) rcossin_tbl [ uVar3 * 2 + 1 ] * 4 ) ;
tanner_collision_box . min_z = ( ( player [ 0 ] . pPed ) - > position ) . vz + index + - 148 ;
tanner_collision_box . max_z = ( ( player [ 0 ] . pPed ) - > position ) . vz + index + 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 ;
p_Var5 = explosion ;
index = 4 ;
collision_boxes_set = iVar4 ;
do {
if ( 0x7ff < p_Var5 - > time ) {
iVar4 = ( p_Var5 - > pos ) . vx ;
2020-07-05 18:32:12 +02:00
extra_collision_boxes [ num_extra_boxes_set ] . min_x = iVar4 - 1952 ;
extra_collision_boxes [ num_extra_boxes_set ] . max_x = iVar4 + 1952 ;
2020-04-03 00:44:09 +02:00
pCVar1 = extra_collision_boxes + num_extra_boxes_set ;
pCVar2 = extra_collision_boxes + num_extra_boxes_set ;
iVar4 = ( p_Var5 - > pos ) . vz ;
num_extra_boxes_set = num_extra_boxes_set + 1 ;
2020-07-05 18:32:12 +02:00
pCVar1 - > min_z = iVar4 - 1952 ;
pCVar2 - > max_z = iVar4 + 1952 ;
2020-04-03 00:44:09 +02:00
}
index = index + - 1 ;
p_Var5 = p_Var5 + 1 ;
} while ( - 1 < index ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// struct _CAR_DATA * /*$ra*/ CheckForCar(struct PEDESTRIAN *pedestrian /*$s3*/)
// line 5178, offset 0x00072738
/* begin block 1 */
// Start line: 5179
// Start offset: 0x00072738
// Variables:
// int count; // $s0
/* begin block 1.1 */
// Start line: 5183
// Start offset: 0x00072770
/* end block 1.1 */
// End offset: 0x00072790
// End Line: 5204
/* begin block 1.2 */
// Start line: 5206
// Start offset: 0x000727B4
/* end block 1.2 */
// End offset: 0x000727B4
// End Line: 5213
/* begin block 1.3 */
// Start line: 5217
// Start offset: 0x00072800
/* end block 1.3 */
// End offset: 0x0007281C
// End Line: 5221
/* end block 1 */
// End offset: 0x0007283C
// End Line: 5223
/* begin block 2 */
// Start line: 19327
/* end block 2 */
// End Line: 19328
/* begin block 3 */
// Start line: 19529
/* end block 3 */
// End Line: 19530
/* begin block 4 */
// Start line: 19531
/* end block 4 */
// End Line: 19532
2020-07-05 18:32:12 +02:00
// [D]
_CAR_DATA * CheckForCar ( PEDESTRIAN * pedestrian )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
int iVar1 ;
int iVar3 ;
2020-07-05 18:32:12 +02:00
CAR_COLLISION_BOX * cb ;
2020-04-03 00:44:09 +02:00
_CAR_DATA * * pp_Var4 ;
iVar3 = 0 ;
2020-07-05 18:32:12 +02:00
if ( 0 < collision_boxes_set )
{
pp_Var4 = collision_car_ptr ;
cb = collision_box ;
2020-04-03 00:44:09 +02:00
do {
2020-07-05 18:32:12 +02:00
iVar3 + + ;
if ( CheckForPlayerCar ( pedestrian , cb ) ! = 0 )
2020-04-03 00:44:09 +02:00
return * pp_Var4 ;
2020-07-05 18:32:12 +02:00
pp_Var4 + + ;
cb + + ;
2020-04-03 00:44:09 +02:00
} while ( iVar3 < collision_boxes_set ) ;
}
iVar3 = 0 ;
2020-07-05 18:32:12 +02:00
2020-04-03 00:44:09 +02:00
while ( ( iVar1 = bAvoidBomb , iVar3 < num_extra_boxes_set & &
2020-07-05 18:32:12 +02:00
( iVar1 = iVar3 , CheckForPlayerCar ( pedestrian , extra_collision_boxes + iVar3 ) = = 0 ) ) )
{
iVar3 + + ;
2020-04-03 00:44:09 +02:00
}
2020-07-05 18:32:12 +02:00
2020-04-03 00:44:09 +02:00
bAvoidBomb = iVar1 ;
2020-07-05 18:32: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
}
// decompiled code
// original method signature:
// int /*$ra*/ CheckForPlayerCar(struct PEDESTRIAN *pedestrian /*$a0*/, struct CAR_COLLISION_BOX *collision_box /*$a1*/)
// line 5231, offset 0x000732c0
/* begin block 1 */
// Start line: 26722
/* end block 1 */
// End Line: 26723
/* begin block 2 */
// Start line: 26723
/* end block 2 */
// End Line: 26724
2020-04-03 00:44:09 +02:00
// [D]
int CheckForPlayerCar ( PEDESTRIAN * pedestrian , CAR_COLLISION_BOX * collision_box )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
int iVar1 ;
iVar1 = ( pedestrian - > position ) . vx ;
if ( ( collision_box - > min_x < = iVar1 ) & & ( iVar1 < = collision_box - > max_x ) ) {
iVar1 = ( pedestrian - > position ) . vz ;
if ( collision_box - > min_z < = iVar1 ) {
return ( uint ) ( collision_box - > max_z < iVar1 ) ^ 1 ;
}
return 0 ;
}
return 0 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CalculatePedestrianInterest(struct PEDESTRIAN *pPed /*$s0*/)
// line 5249, offset 0x00071e0c
/* begin block 1 */
// Start line: 5250
// Start offset: 0x00071E0C
// Variables:
// int interest; // $a2
// int dist; // $v1
// struct _CAR_DATA *pCar; // $a2
// struct VECTOR v1; // stack offset -40
// struct VECTOR v2; // stack offset -24
/* end block 1 */
// End offset: 0x00071F44
// End Line: 5318
/* begin block 2 */
// Start line: 12043
/* end block 2 */
// End Line: 12044
/* begin block 3 */
// Start line: 12122
/* end block 3 */
// End Line: 12123
/* begin block 4 */
// Start line: 12128
/* end block 4 */
// End Line: 12129
2020-05-15 12:54:05 +02:00
int basic_car_interest ;
// [D]
2020-03-27 21:47:29 +01:00
void CalculatePedestrianInterest ( PEDESTRIAN * pPed )
{
2020-09-08 15:43:00 +02:00
_CAR_DATA * pCar ;
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-08-11 16:39:40 +02:00
return ;
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-09-08 15:43:00 +02:00
if ( dist < 6001 )
interest = 6000 - dist ;
else
interest = 0 ;
2020-05-15 12:54:05 +02:00
if ( pPed - > type = = PED_ACTION_JUMP )
{
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
}
// decompiled code
// original method signature:
// int /*$ra*/ PedSurfaceType(struct VECTOR *ped_pos /*$a0*/)
// line 5325, offset 0x00072584
/* begin block 1 */
// Start line: 5330
// Start offset: 0x00072584
// Variables:
// struct _sdPlane *sfc_ptr; // $v0
/* end block 1 */
// End offset: 0x000725B8
// End Line: 5335
/* begin block 2 */
// Start line: 18922
/* end block 2 */
// End Line: 18923
/* begin block 3 */
// Start line: 19313
/* end block 3 */
// End Line: 19314
/* begin block 4 */
// Start line: 19317
/* end block 4 */
// End Line: 19318
int PedSurfaceType ( VECTOR * ped_pos )
{
2020-05-15 12:54:05 +02:00
_sdPlane * sfc_ptr ;
sfc_ptr = sdGetCell ( ped_pos ) ;
2020-04-03 00:44:09 +02:00
2020-05-15 12:54:05 +02:00
if ( ! sfc_ptr )
return 0 ;
return sfc_ptr - > surface ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ ProcessChairLump(char *lump_file /*$a0*/, int lump_size /*$a1*/)
// line 5344, offset 0x00073328
/* begin block 1 */
// Start line: 26847
/* end block 1 */
// End Line: 26848
/* begin block 2 */
// Start line: 26951
/* end block 2 */
// End Line: 26952
/* begin block 3 */
// Start line: 26952
/* end block 3 */
// End Line: 26953
2020-04-03 00:44:09 +02:00
void ProcessChairLump ( char * lump_file , int lump_size )
2020-03-27 21:47:29 +01:00
{
2020-04-03 00:44:09 +02:00
seated_pedestrian = ( SEATED_PEDESTRIANS * ) lump_file ;
2020-03-27 21:47:29 +01:00
}