Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Summer Special
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

      1. St Andrews Cathedral
    3. GTA V

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

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

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    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. DYOM
      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
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Expendable

Get Current Ped Animation in GTA SA

Recommended Posts

Expendable

Does anyone have a clever way to quickly determine a ped's current animation in GTA SA? There isn't an opcode to "get" or "store" the current animation and, for performance reasons, I wouldn't want to check every possible animation using 0611: actor [email protected] performing_animation "(this or that)" until I find the right one.

Share this post


Link to post
Share on other sites
Expendable

Oh well. Okay.

Luckily, for my purposes, the actor is either going to be sitting, standing, or sleeping. So no big deal checking it with if/else. :)

Edited by Expendable

Share this post


Link to post
Share on other sites
Expendable

Perhaps I can get the actor_struct...

0AEA: [email protected] = actor_struct [email protected] handle

and apply this offset...

+0x47C (Pointer to anim struct)

...to read the current animation?

Share this post


Link to post
Share on other sites
ZAZ

do you wanna display the anim name? or what's the reason, that you won't do it with 0611?

Share this post


Link to post
Share on other sites
Expendable

do you wanna display the anim name? or what's the reason, that you won't do it with 0611?

 

No, I don't want to display the anim name, I want to use it to animate the ped. I'm still working on controlling/scripting the peds in a burglary house. I want to use part of the script you showed me to find all the peds...

for [email protected] = 0 to 35584 step 256  0085: [email protected] = [email protected]  for [email protected] = 0 to 127      if and          056D:   actor [email protected] defined  // if we've got an actor          803C:   not $PLAYER_ACTOR == [email protected]  // make sure we've not got the player.      then          if              00EC:   actor [email protected] 0 near_point 0.0 0.0 radius 10.0 10.0  // coordinates the actor must be near          then              0321: kill_actor [email protected]              break          end      end      000A: [email protected] += 1  endend 

Once I find a ped in the loop, I'll replace it with an exact duplicate that I can control and destroy the original script-generated ped. That much I've done, no problems. But if the ped was sleeping, I want my newly created ped to sleep. If the ped was sitting, I want the new ped to be sitting. So I need to know what animation they were currently using.

 

If I use an if/else loop to determine the animation (0611: actor [email protected] performing_animation "(this or that)"), then I fear it may slow things down too much and become a performance issue. Deji's script above is probably going to take a bit of time to find all the peds. I don't want to slow the process down worse by adding a list of tests to discover the ped's animation.

 

I was hoping there might be a quicker way to determine the animation. Probably not though.

Edited by Expendable

Share this post


Link to post
Share on other sites
HeresOtis

By looking into the idb, it seems somewhat tedious to get the current animation.

Share this post


Link to post
Share on other sites
Expendable

The other option is tempting, but won't work....

 

Instead of replacing all the script-generated peds in the burglary house (so I can control/script them), I can start by destroying all the peds in the interior to begin with and create new ones altogether. Then I can animate them any way I want.

 

Problem is, although the interiors are limited in number (I think there's 5 or 6 different burglary house interiors), the LAYOUT of the furniture can change. So, I won't know exactly where to place the sleeping ped or the sitting ped (or whatever) in a given interior unless I can gets those coords from the existing peds. So I can't destroy them until I replace them. When I replace them, I'll nee their current animation to position them properly. Smell what The Rock is cookin'? :)

So I think it's a better idea to use the peds that the script generated--get each ped_type, model, coordinates--and simply create a new one in its place that I can control/script. All I need to know is the animation the script-generated ped is performing.

lol, see my problem now? :)

----------------------------------

 

But maybe there's also another way!

If I could read the ped's animation from a memory location, that would be great.

Edited by Expendable

Share this post


Link to post
Share on other sites
HeresOtis

What do you plan on doing if you were able to get control of the game-created peds and their animation?

Share this post


Link to post
Share on other sites
Expendable

If I can replace the burglary peds with duplicates that are performing the proper animation, I'll make them do things like handsup, run away, escape when CJ isn't watching them, targeted peds will cower if ordered, dance if ordered, drop all their money if ordered, or whatever. The world is my oyster. :)

 

My intention is to create realistic home invasions that can occur at any time, not just when you're on a burglary mission. The police will show up if a ped escapes (alerting the neighbors), or calls them. Too much noise or gunfire will cause the neighbors to call the police. Etc.

Edited by Expendable

Share this post


Link to post
Share on other sites
HeresOtis

What's wrong with getting the handle of those peds and just changing their animation instead of creating new peds?

Share this post


Link to post
Share on other sites
Expendable

Ever tried it? You can't change the animation of a ped in a burglary house. Game won't allow it. I can get the handle, but I can't control or script the ped. The only way is to replace them.

Share this post


Link to post
Share on other sites
HeresOtis

Make use of this function:

void CPed::SetCharCreatedBy(unsigned char createdBy){	((void (__thiscall *)(CPed*, unsigned char))0x5E47E0)(this, createdBy);}

You will be using 2 as the parameter.

I believe in CLEO:

0A96: get_char_pointer $PLAYER_ACTOR store_to [email protected]: call_method 0x5E47E0 struct [email protected] num_params 1 pop 0 2

After applying that code to the actor, then you should be able to control them easily.

  • Like 1

Share this post


Link to post
Share on other sites
Expendable

Thanks! I'll try that. :)

 

 

Uh... While I have your ear...

 

Can you think of a faster/more efficient/simplified way to find all the the peds in an interior than Deji's "universal" method?

for [email protected] = 0 to 35584 step 256  0085: [email protected] = [email protected]  for [email protected] = 0 to 127      if and          056D:   actor [email protected] defined  // if we've got an actor          803C:   not $PLAYER_ACTOR == [email protected]  // make sure we've not got the player.      then          if              00EC:   actor [email protected] 0 near_point 0.0 0.0 radius 10.0 10.0  // coordinates the actor must be near          then              0321: kill_actor [email protected]              break          end      end      000A: [email protected] += 1  endend

Burglary house interiors usually only have 2 or 3 peds. I'm not sure this would be the most efficient way to capture them.

Thanks for any help.

Share this post


Link to post
Share on other sites
Expendable

 

0A96: get_char_pointer $PLAYER_ACTOR store_to [email protected]: call_method 0x5E47E0 struct [email protected] num_params 1 pop 0 2

Thanks, but that didn't work.

 

I believe I'm using it correctly. In my script, the ped handle is [email protected]

 

0A96: get_char_pointer [email protected] store_to [email protected]

0AA6: call_method 0x5E47E0 struct [email protected] num_params 1 pop 0 2

 

Using this code causes the game to immediately close.

Share this post


Link to post
Share on other sites
Expendable

 

I changed 0A96: get_char_pointer [email protected] store_to [email protected]

 

to 0A96: [email protected] = actor [email protected] struct to resolve the error. Maybe the opcode you posted wasn't compiling correctly.

 

 

 

But, it still doesn't allow me to animate the ped using 0812: AS_actor [email protected] perform_animation. Back to square one. :/

 

Share this post


Link to post
Share on other sites
HeresOtis

That means you had a different opcode database, so the parameters were reversed and caused crashing. Are you loading the animation file?

Share this post


Link to post
Share on other sites
Expendable

Are you loading the animation file?

 

Yes.

 

Let me back up a little... The only way I've found to get a ped's handle in a burglary house, besides Deji's method of scanning memory (above), is to target the ped. The normal methods (073F: get_actor_in_sphere, ETC...) don't work, but fortunately targeting the ped actually works to get its handle.

 

I use this opcode:

0AD2: [email protected] = player $PLAYER_CHAR targeted_actor //IF and SET

 

Once I have the handle, I can actually do some things with the ped. I can (at least) do the following...

 

[email protected] = Marker.CreateAboveActor([email protected])

0631: put_actor [email protected] in_group $PLAYER_GROUP

06C9: remove_actor [email protected] from_group

Actor.PutAt([email protected], [email protected], [email protected], [email protected])

Actor.Angle([email protected]) = [email protected]

 

But unfortunately the ped won't perform animations. Not even simple ones like handsup, cower, chew gum, etc.

 

Anyway, after I have the handle, I tried applying your code...

0A96: [email protected] = actor [email protected] struct

0AA6: call_method 0x5E47E0 struct [email protected] num_params 1 pop 0 2

 

No results, didn't work, but anyway...

 

Then I load the animation.

04ED: load_animation "whatever"

 

Check to be sure it's loaded.

:LOAD_CHK

0001: wait 0 ms

00D6: if

04EE: animation "whatever" loaded

004D: jump_if_false @LOAD_CHK

 

Then I attempt to have the ped perform the animation....

0812: AS_actor [email protected] perform_animation "whatever" (blah blah blah)

 

But, as usual, burglary house peds won't perform animations! ZAZ said...

 

R* opcodes to get random actor don't gets actors that are handled by another script, also raraly cops and gang members...

So my solution is... If I can't control peds in a burglary house, I'll destroy them and create duplicates that I can control. Trouble is, I need to know their current animation such as sleeping, sitting, etc., so I can set the peds in the interior properly, and the home invasion scenario can begin just as if you were on a burglary mission.

 

OR, I need to find some other way to control the peds, which is what I was hoping your method (below) could do.

0A96: [email protected] = actor [email protected] struct0AA6: call_method 0x5E47E0 struct [email protected] num_params 1 pop 0 2

I hope my problem a little more clear now. :)

Share this post


Link to post
Share on other sites
HeresOtis

Yea, idk. It would be simpler in c++.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.