Flags são bits que indicam verdadeiro ou falso, muito utilizados para armazenar pequenas informações como "a pessoa está dentro de algum veículo?", "a pessoa está se afogando?", "o veículo está com o motor ligado?", "o veículo está em processo de estacionar?".
Várias das informações não são atualmente disponíveis na CLEO e MoonLoader.
Importante: É necessário ter conhecimento sobre
manipulação de memória.
Se você usa
plugin-sdk, a única utilidade deste tópico é
"ei, você pode fazer isto!".
Como ler as flags
É claro que várias e várias classes do jogo usam flags, mas eu vou mostrar as duas principais:
pessoas e veículos.
Aprendendo isto você já saberá lidar com outras que ver no futuro.
Pessoas (CHAR):
Não há só 1, mas 4:
CPed+0x46C
CPed+0x470
CPed+0x474
CPed+0x478
São 4 bytes cada (32 bits), num total de 117 bits (há só 21 bits utilizados na última) com informações que lhe podem ser úteis:
Código: Selecionar tudo
0000046C pedFlags dd ?
unsigned int bIsStanding : 1; // is ped standing on something
unsigned int bWasStanding : 1; // was ped standing on something
unsigned int bIsLooking : 1; // is ped looking at something or in a direction
unsigned int bIsRestoringLook : 1; // is ped restoring head postion from a look
unsigned int bIsAimingGun : 1; // is ped aiming gun
unsigned int bIsRestoringGun : 1; // is ped moving gun back to default posn
unsigned int bCanPointGunAtTarget : 1; // can ped point gun at target
unsigned int bIsTalking : 1; // is ped talking(see Chat())
unsigned int bInVehicle : 1; // is in a vehicle
unsigned int bIsInTheAir : 1; // is in the air
unsigned int bIsLanding : 1; // is landing after being in the air
unsigned int bHitSomethingLastFrame : 1; // has been in a collision last fram
unsigned int bIsNearCar : 1;
unsigned int bRenderPedInCar : 1;
unsigned int bUpdateAnimHeading : 1; // update ped heading due to heading change during anim sequence
unsigned int bRemoveHead : 1; // waiting on AntiSpazTimer to remove head
unsigned int bFiringWeapon : 1; // is pulling trigger
unsigned int bHasACamera : 1; // does ped possess a camera to document accidents
unsigned int bPedIsBleeding : 1; // Ped loses a lot of blood if true
unsigned int bStopAndShoot : 1; // Ped cannot reach target to attack with fist, need to use gun
unsigned int bIsPedDieAnimPlaying : 1; // is ped die animation finished so can dead now
unsigned int bStayInSamePlace : 1; // when set, ped stays put
unsigned int bKindaStayInSamePlace : 1; // when set, ped doesn't seek out opponent or cover large distances. Will still shuffle and look for cover
unsigned int bBeingChasedByPolice : 1; // use nodes for routefind
unsigned int bNotAllowedToDuck : 1; // Is this ped allowed to duck at all?
unsigned int bCrouchWhenShooting : 1; // duck behind cars etc
unsigned int bIsDucking : 1; // duck behind cars etc
unsigned int bGetUpAnimStarted : 1; // don't want to play getup anim if under something
unsigned int bDoBloodyFootprints : 1; // unsigned int bIsLeader :1;
unsigned int bDontDragMeOutCar : 1;
unsigned int bStillOnValidPoly : 1; // set if the polygon the ped is on is still valid for collision
unsigned int bAllowMedicsToReviveMe : 1;
00000470 pedFlags dd ?
unsigned int bResetWalkAnims : 1;
unsigned int bOnBoat : 1; // flee but only using nodes
unsigned int bBusJacked : 1; // flee but only using nodes
unsigned int bFadeOut : 1; // set if you want ped to fade out
unsigned int bKnockedUpIntoAir : 1; // has ped been knocked up into the air by a car collision
unsigned int bHitSteepSlope : 1; // has ped collided/is standing on a steep slope (surface type)
unsigned int bCullExtraFarAway : 1; // special ped only gets culled if it's extra far away (for roadblocks)
unsigned int bTryingToReachDryLand : 1; // has ped just exited boat and trying to get to dry land
unsigned int bCollidedWithMyVehicle : 1;
unsigned int bRichFromMugging : 1; // ped has lots of cash cause they've been mugging people
unsigned int bChrisCriminal : 1; // Is a criminal as killed during Chris' police mission (should be counted as such)
unsigned int bShakeFist : 1; // test shake hand at look entity
unsigned int bNoCriticalHits : 1; // ped cannot be killed by a single bullet
unsigned int bHasAlreadyBeenRecorded : 1; // Used for replays
unsigned int bUpdateMatricesRequired : 1; // if PedIK has altered bones so matrices need updated this frame
unsigned int bFleeWhenStanding : 1; //
unsigned int bMiamiViceCop : 1; //
unsigned int bMoneyHasBeenGivenByScript : 1; //
unsigned int bHasBeenPhotographed : 1; //
unsigned int bIsDrowning : 1;
unsigned int bDrownsInWater : 1;
unsigned int bHeadStuckInCollision : 1;
unsigned int bDeadPedInFrontOfCar : 1;
unsigned int bStayInCarOnJack : 1;
unsigned int bDontFight : 1;
unsigned int bDoomAim : 1;
unsigned int bCanBeShotInVehicle : 1;
unsigned int bPushedAlongByCar : 1; // ped is getting pushed along by car collision (so don't take damage from horz velocity)
unsigned int bNeverEverTargetThisPed : 1;
unsigned int bThisPedIsATargetPriority : 1;
unsigned int bCrouchWhenScared : 1;
unsigned int bKnockedOffBike : 1;
00000474 pedFlags dd ?
unsigned int bDonePositionOutOfCollision : 1;
unsigned int bDontRender : 1;
unsigned int bHasBeenAddedToPopulation : 1;
unsigned int bHasJustLeftCar : 1;
unsigned int bIsInDisguise : 1;
unsigned int bDoesntListenToPlayerGroupCommands : 1;
unsigned int bIsBeingArrested : 1;
unsigned int bHasJustSoughtCover : 1;
unsigned int bKilledByStealth : 1;
unsigned int bDoesntDropWeaponsWhenDead : 1;
unsigned int bCalledPreRender : 1;
unsigned int bBloodPuddleCreated : 1; // Has a static puddle of blood been created yet
unsigned int bPartOfAttackWave : 1;
unsigned int bClearRadarBlipOnDeath : 1;
unsigned int bNeverLeavesGroup : 1; // flag that we want to test 3 extra spheres on col model
unsigned int bTestForBlockedPositions : 1; // this sets these indicator flags for various posisions on the front of the ped
unsigned int bRightArmBlocked : 1;
unsigned int bLeftArmBlocked : 1;
unsigned int bDuckRightArmBlocked : 1;
unsigned int bMidriffBlockedForJump : 1;
unsigned int bFallenDown : 1;
unsigned int bUseAttractorInstantly : 1;
unsigned int bDontAcceptIKLookAts : 1;
unsigned int bHasAScriptBrain : 1;
unsigned int bWaitingForScriptBrainToLoad : 1;
unsigned int bHasGroupDriveTask : 1;
unsigned int bCanExitCar : 1;
unsigned int CantBeKnockedOffBike : 2; // 0=Default(harder for mission peds) 1=Never 2=Always normal(also for mission peds)
unsigned int bHasBeenRendered : 1;
unsigned int bIsCached : 1;
unsigned int bPushOtherPeds : 1; // GETS RESET EVERY FRAME - SET IN TASK: want to push other peds around (eg. leader of a group or ped trying to get in a car)
00000478 pedFlags dd ?
unsigned int bHasBulletProofVest : 1;
unsigned int bUsingMobilePhone : 1;
unsigned int bUpperBodyDamageAnimsOnly : 1;
unsigned int bStuckUnderCar : 1;
unsigned int bKeepTasksAfterCleanUp : 1; // If true ped will carry on with task even after cleanup
unsigned int bIsDyingStuck : 1;
unsigned int bIgnoreHeightCheckOnGotoPointTask : 1; // set when walking round buildings, reset when task quits
unsigned int bForceDieInCar : 1;
unsigned int bCheckColAboveHead : 1;
unsigned int bIgnoreWeaponRange : 1;
unsigned int bDruggedUp : 1;
unsigned int bWantedByPolice : 1; // if this is set, the cops will always go after this ped when they are doing a KillCriminal task
unsigned int bSignalAfterKill : 1;
unsigned int bCanClimbOntoBoat : 1;
unsigned int bPedHitWallLastFrame : 1; // useful to store this so that AI knows (normal will still be available)
unsigned int bIgnoreHeightDifferenceFollowingNodes : 1;
unsigned int bMoveAnimSpeedHasBeenSetByTask : 1;
unsigned int bGetOutUpsideDownCar : 1;
unsigned int bJustGotOffTrain : 1;
unsigned int bDeathPickupsPersist : 1;
unsigned int bTestForShotInVehicle : 1;
unsigned int bUsedForReplay : 1; // This ped is controlled by replay and should be removed when replay is done.
O código acima foi pego do plugin-sdk, veja na íntegra e atualizado
aqui.
Offsets do
IDA.txt.
Veículos (CAR):
Há 2, também 4 bytes:
CVehicle+0x428
CVehicle+0x42C
Código: Selecionar tudo
00000428 m_nFlags dd ?
unsigned char bIsLawEnforcer : 1; // Is this guy chasing the player at the moment
unsigned char bIsAmbulanceOnDuty : 1; // Ambulance trying to get to an accident
unsigned char bIsFireTruckOnDuty : 1; // Firetruck trying to get to a fire
unsigned char bIsLocked : 1; // Is this guy locked by the script (cannot be removed)
unsigned char bEngineOn : 1; // For sound purposes. Parked cars have their engines switched off (so do destroyed cars)
unsigned char bIsHandbrakeOn : 1; // How's the handbrake doing ?
unsigned char bLightsOn : 1; // Are the lights switched on ?
unsigned char bFreebies : 1; // Any freebies left in this vehicle ?
unsigned char bIsVan : 1; // Is this vehicle a van (doors at back of vehicle)
unsigned char bIsBus : 1; // Is this vehicle a bus
unsigned char bIsBig : 1; // Is this vehicle a bus
unsigned char bLowVehicle : 1; // Need this for sporty type cars to use low getting-in/out anims
unsigned char bComedyControls : 1; // Will make the car hard to control (hopefully in a funny way)
unsigned char bWarnedPeds : 1; // Has scan and warn peds of danger been processed?
unsigned char bCraneMessageDone : 1; // A crane message has been printed for this car allready
unsigned char bTakeLessDamage : 1; // This vehicle is stronger (takes about 1/4 of damage)
unsigned char bIsDamaged : 1; // This vehicle has been damaged and is displaying all its components
unsigned char bHasBeenOwnedByPlayer : 1;// To work out whether stealing it is a crime
unsigned char bFadeOut : 1; // Fade vehicle out
unsigned char bIsBeingCarJacked : 1; // Fade vehicle out
unsigned char bCreateRoadBlockPeds : 1;// If this vehicle gets close enough we will create peds (coppers or gang members) round it
unsigned char bCanBeDamaged : 1; // Set to FALSE during cut scenes to avoid explosions
unsigned char bOccupantsHaveBeenGenerated : 1; // Is true if the occupants have already been generated. (Shouldn't happen again)
unsigned char bGunSwitchedOff : 1; // Level designers can use this to switch off guns on boats
unsigned char bVehicleColProcessed : 1;// Has ProcessEntityCollision been processed for this car?
unsigned char bIsCarParkVehicle : 1; // Car has been created using the special CAR_PARK script command
unsigned char bHasAlreadyBeenRecorded : 1; // Used for replays
unsigned char bPartOfConvoy : 1;
unsigned char bHeliMinimumTilt : 1; // This heli should have almost no tilt really
unsigned char bAudioChangingGear : 1; // sounds like vehicle is changing gear
unsigned char bIsDrowning : 1; // is vehicle occupants taking damage in water (i.e. vehicle is dead in water)
unsigned char bTyresDontBurst : 1; // If this is set the tyres are invincible
0000042C m_nFlags dd ?
unsigned char bCreatedAsPoliceVehicle : 1;// True if this guy was created as a police vehicle (enforcer, policecar, miamivice car etc)
unsigned char bRestingOnPhysical : 1; // Dont go static cause car is sitting on a physical object that might get removed
unsigned char bParking : 1;
unsigned char bCanPark : 1;
unsigned char bFireGun : 1; // Does the ai of this vehicle want to fire it's gun?
unsigned char bDriverLastFrame : 1; // Was there a driver present last frame ?
unsigned char bNeverUseSmallerRemovalRange : 1;// Some vehicles (like planes) we don't want to remove just behind the camera.
unsigned char bIsRCVehicle : 1; // Is this a remote controlled (small) vehicle. True whether the player or AI controls it.
unsigned char bAlwaysSkidMarks : 1; // This vehicle leaves skidmarks regardless of the wheels' states.
unsigned char bEngineBroken : 1; // Engine doesn't work. Player can get in but the vehicle won't drive
unsigned char bVehicleCanBeTargetted : 1;// The ped driving this vehicle can be targetted, (for Torenos plane mission)
unsigned char bPartOfAttackWave : 1; // This car is used in an attack during a gang war
unsigned char bWinchCanPickMeUp : 1; // This car cannot be picked up by any ropes.
unsigned char bImpounded : 1; // Has this vehicle been in a police impounding garage
unsigned char bVehicleCanBeTargettedByHS : 1;// Heat seeking missiles will not target this vehicle.
unsigned char bSirenOrAlarm : 1; // Set to TRUE if siren or alarm active, else FALSE
unsigned char bHasGangLeaningOn : 1;
unsigned char bGangMembersForRoadBlock : 1;// Will generate gang members if NumPedsForRoadBlock > 0
unsigned char bDoesProvideCover : 1; // If this is false this particular vehicle can not be used to take cover behind.
unsigned char bMadDriver : 1; // This vehicle is driving like a lunatic
unsigned char bUpgradedStereo : 1; // This vehicle has an upgraded stereo
unsigned char bConsideredByPlayer : 1; // This vehicle is considered by the player to enter
unsigned char bPetrolTankIsWeakPoint : 1;// If false shootong the petrol tank will NOT Blow up the car
unsigned char bDisableParticles : 1; // Disable particles from this car. Used in garage.
unsigned char bHasBeenResprayed : 1; // Has been resprayed in a respray garage. Reset after it has been checked.
unsigned char bUseCarCheats : 1; // If this is true will set the car cheat stuff up in ProcessControl()
unsigned char bDontSetColourWhenRemapping : 1;// If the texture gets remapped we don't want to change the colour with it.
unsigned char bUsedForReplay : 1; // This car is controlled by replay and should be removed when replay is done.
O código acima foi pego do plugin-sdk, veja na íntegra e atualizado
aqui.
Offsets do
IDA.txt.
Exemplos:
gta3script
Código: Selecionar tudo
GET_PED_POINTER hChar pChar
flags = pChar + 0x474
READ_MEMORY flags 4 FALSE (flags)
IF IS_LOCAL_VAR_BIT_SET_CONST flags 23 //bHasAScriptBrain
No exemplo acima nós checamos se um char é controlado por um "brain" de multifile (usado no main.scm com uns scripts do script.img), isto é, retornará verdadeiro em vendedores de drogas ativos, vendedores em carrinhos de hot dog, mendigos sendo controlados por
este mod etc.
Sim, você terá que contar para saber qual é o número de cada flag, lembrando que a contagem começa do 0 (ou seja, vai de 0 à 31).
Se você está confuso, vá onde está marcado o offset
0x474
e conte as linhas abaixo a partir de 0, na linha 23 você encontrará
bHasAScriptBrain
.
Você também pode ver qual o valor das flags e colocar na calculadora do Windows no modo "Programador". No binário (
BIN
) você verá os bits lá.
Do mesmo modo que você pode checar com
IS_LOCAL_VAR_BIT_SET_CONST
, você pode setar com
SET_LOCAL_VAR_BIT_CONST
, ou limpar com
CLEAR_LOCAL_VAR_BIT_CONST
, ou até mesmo utilizar operadores
bitwise. No entanto, várias flags só servem como algum tipo de informação temporária, portanto não fará diferença caso alterá-las.
É recomendado que você não crie uso para flags não utilizadas.