Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

How to edit despawn timer for dead peds?


Blablabla69420
 Share

Recommended Posts

Blablabla69420

need instructions for this

 

You know that, after a certain amount of time, a dead ped despawns even if you're looking at it.

That uses a timer. how do i edit that timer?

 

Which file contains the despawn timer for dead peds?

What to edit in said file?

Which directory?

Need help with this.

Link to comment
Share on other sites

Blablabla69420
7 hours ago, firedihm said:

they are hardcoded

Can you just like, give it a try?

Why would there be no way to change the code?

Link to comment
Share on other sites

30 seconds = 30 000 ms   //  0x7530      
binary search:  30 75 00 00

This function is directly responsible for that:

0x611FC0  //    CPopulation::ManagePed(CPed *ped, CVector *playerPosn);

Decompiled to c++:

Spoiler
void __cdecl CPopulation::ManagePed(CPed *ped, CVector *playerPosn)
{
  int v2; // [email protected]
  CEntity *v3; // [email protected]
  int delta; // [email protected]
  CCoors *v5; // [email protected]
  int v6; // [email protected]
  double v7; // [email protected]
  int v8; // [email protected]
  double v9; // [email protected]
  int v10; // [email protected]
  char v11; // [email protected]
  int v12; // [email protected]
  int v13; // [email protected]
  WORD v14; // [email protected]
  float v15; // [sp+4h] [bp-4h]@20

  if ( CPed::IsPlayer(ped) )
    return;
  if ( !CPed::CanBeDeleted(ped) )
    return;
  v2 = ped->m_dwPedFlags[0];
  if ( BYTE1(v2) & 1 )
    return;
  v3 = (CEntity *)ped->physical.m_pAttachedTo;
  if ( v3 )
  {
    if ( (v3->m_bTypeState & 7) == ENTITY_TYPE_VEHICLE )
      return;
  }
  delta = CTimer::m_snTimeInMilliseconds - ped->m_dwTimeWhenDead;   //  ---> RELEVANT !!! <---
  if ( ped->m_dwPedState == 55
    && (delta > 30000 || CDarkel::FrenzyOnGoing() && delta > 15000 || delta > 8000
                                                                   && CGangWars::GangWarFightingGoingOn()) )
    ped->m_dwPedFlags[1] |= PED_FADE_OUT;
  if ( ped->m_dwPedFlags[1] & PED_FADE_OUT && !CVisibilityPlugins::GetClumpAlpha(ped->physical.entity.m_pRWObject) )
  {
@@REMOVE_PED:
    CPopulation::RemovePed((_CEntity *)ped);
    return;
  }
  v5 = ped->physical.entity.placeable.m_pCoords;
  v6 = (int)&v5->m_mMatrix.matrix.pos;
  if ( !v5 )
    v6 = (int)&ped->physical.entity.placeable.m_SimpleCoors;
  if ( v5 )
    v8 = (int)&v5->m_mMatrix.matrix.pos;
  else
    v8 = (int)&ped->physical.entity.placeable.m_SimpleCoors;
  v9 = *(float *)(v8 + 4);
  v10 = ped->m_nPedType;
  v7 = *(float *)v6 - playerPosn->x;
  v15 = sqrt((v9 - playerPosn->y) * (v9 - playerPosn->y) + v7 * v7) * ped->m_fRemovalDistMultiplier;
  if ( v10 < 7 || v10 > 16 )
  {
    if ( ped->m_dwPedFlags[1] & DEAD_PED_IN_FRONT_OF_CAR && ped->field_590 )
      v15 = 0.0;
  }
  else
  {
    v15 = v15 - 30.0;
  }
  if ( CPopulation::PedCreationDistMultiplier() * TheCamera.m_fGenerationDistMultiplier * 65.0 < v15
    || !(ped->m_dwPedFlags[1] & CULL_EXTRA_FAR_AWAY)
    && CPopulation::PedCreationDistMultiplier() * TheCamera.m_fGenerationDistMultiplier * 54.5 < v15 )
  {
@@FADEOUTPEDORREMOVE:
    if ( CEntity::GetIsOnScreen(&ped->physical.entity) )
    {
      ped->m_dwPedFlags[1] |= PED_FADE_OUT;
      return;
    }
    goto @@REMOVE_PED;
  }
  if ( CPopulation::PedCreationDistMultiplier() * 25.0 >= v15 )
  {
    if ( ped->m_nPedType != 6 )
    {
      ped->m_dwTimeTillWeNeedThisPed = CTimer::m_snTimeInMilliseconds + 4000;
      return;
    }
    v12 = CTimer::m_snTimeInMilliseconds;
LABEL_45:
    ped->m_dwTimeTillWeNeedThisPed = v12 + 10000;
    return;
  }
  v11 = CEntity::GetIsOnScreen(&ped->physical.entity);
  v12 = CTimer::m_snTimeInMilliseconds;
  if ( (unsigned int)CTimer::m_snTimeInMilliseconds <= ped->m_dwTimeTillWeNeedThisPed )
  {
    if ( !v11 )
      return;
LABEL_41:
    if ( ped->m_nPedType != 6 )
    {
      ped->m_dwTimeTillWeNeedThisPed = CTimer::m_snTimeInMilliseconds + 4000;
      return;
    }
    goto LABEL_45;
  }
  if ( v11 )
    goto LABEL_41;
  v13 = TheCamera.m_nActiveCam;
  v14 = TheCamera.m_aCams[v13].m_wMode;
  if ( v14 != 7
    && v14 != 39
    && v14 != 46
    && !TheCamera.m_aCams[v13].m_bLookingLeft
    && !TheCamera.m_aCams[v13].m_bLookingRight
    && !TheCamera.m_aCams[v13].m_bLookingBehind )
    goto @@FADEOUTPEDORREMOVE;
    
    
}

 

Solutions:
Increasing the delta clock to a max DWORD value:

injector::WriteMemory<DWORD>(0x612024 + 2, -1); //  30000 as a default

or disabling the cond. check jump which will completely remove the clock:

injector::MakeNOP(0x61202A, 2);  //  default 0x227F

However if we look at the biger picture this memory changes should occur under some specific circumstances like when the player is close to a dead ped or when a ped is in his field of view. Otherwise that piece of code should be returned to the default again in order to avoid potential issues.
 

Edited by Jack
Link to comment
Share on other sites

Blablabla69420

Understood.

Now, which filename?

Link to comment
Share on other sites

If you want it just for gameplay you can use the MixSets mod.

Link to comment
Share on other sites

Blablabla69420
18 minutes ago, cjfan_ said:

If you want it just for gameplay you can use the MixSets mod.

Yes, I want it for only gameplay. Download link?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.