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. The Diamond Casino Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. 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

krvger

Thread memory fail

Recommended Posts

krvger

Hello,

 

Due to its limitations of number of local variables in VC I started to mess around with thread memory. However, whenever the script would find a ped it crashes. Please help me to solve this problem :)

Thanks in advance,

KRVGER

{$CLEO .cs}0000: NOPconst    PLAYER_X = [email protected]    PLAYER_Y = [email protected]    PLAYER_Z = [email protected]    ZOMBIE = [email protected]    GUN = [email protected]    ZOMBIE_COUNTER = [email protected]    MEMORY = [email protected]    MARKER = [email protected]    ZEROER = [email protected]    [email protected] : float    [email protected] : float    [email protected] : float    [email protected] : int    [email protected] : int        [email protected] : int    [email protected] : int    [email protected] : int    [email protected] : intendZEROER = 00 00 00 00:STARTwhile true    wait 300 ms    if  Player.Defined($PLAYER_CHAR)    then        0054: store_player $PLAYER_CHAR position_to PLAYER_X PLAYER_Y PLAYER_Z        if  05EF: ZOMBIE = random_actor_near_point PLAYER_X PLAYER_Y PLAYER_Z in_radius 25.0 find_next 0 pass_deads 1 //IF and SET        then            for ZOMBIE_COUNTER = 18 TO 25 step 1                05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER MEMORY     // Check for used memory                if MEMORY == 0                then                    break                end                                                              end                         if and                05F5: call_scm_func @PED_CHECK params_count 1 ZOMBIE    // Is actor police or mission ped                02D8: actor ZOMBIE current_weapon == 0             then                0209: GUN = random_int_in_ranges 259 270                0247: request_model GUN                038B: load_requested_models                 GUN -= 258                                01B2: give_actor ZOMBIE weapon GUN ammo 0 // Load the weapon model before using this                if GUN == 11                then                    0245: set_actor ZOMBIE walk_style_to 35                 end                 01CC: actor ZOMBIE kill_player $PLAYER_CHAR                05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER ZOMBIE  // Write actor to non-occupied space                0187: MARKER = create_marker_above_actor ZOMBIE                ZOMBIE_COUNTER += 32                05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER MARKER  // Write its marker to another one            end            while true                wait 0 ms                for ZOMBIE_COUNTER = 18 TO 25 step 1                    05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER ZOMBIE                     if or                        ZOMBIE == 0                        0118:   actor ZOMBIE dead                        80FB:   NOT player $PLAYER_CHAR 0 near_actor ZOMBIE radius 100.0 100.0 100.0                    then                                                                                // Memory flushing                        MEMORY = ZOMBIE_COUNTER                                                                         MEMORY += 32                        05F5: call_scm_func @READ_FROM_MEM params_count 1 MEMORY MARKER                        0164: disable_marker MARKER                        05F5: call_scm_func @WRITE_TO_MEM params_count 2 MEMORY ZEROER                        01C2: remove_references_to_actor ZOMBIE // Like turning an actor into a random pedestrian                        05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER ZEROER                                             jump @START                    end                end                                                              end        end     endend:PED_CHECK05E6: [email protected] = actor [email protected] struct0085: [email protected] = [email protected]@ += [email protected] += 0x16005E0: [email protected] = read_memory [email protected] size 2 virtual_protect 005E0: [email protected] = read_memory [email protected] size 2 virtual_protect [email protected] == 1not [email protected] == 1not [email protected] == 2not [email protected] == 3not [email protected] == 4not [email protected] == 5not [email protected] == 6not [email protected] == 97not [email protected] == 98not [email protected] == 99not [email protected] == 100not [email protected] == 101not [email protected] == 102not [email protected] == 103not [email protected] == 10405F6: ret 0:WRITE_TO_MEM05F5: call_scm_func @GET_LOCATION params_count 1 [email protected] [email protected]: write_memory [email protected] size 4 value [email protected] virtual_protect 005F6: ret 0:READ_FROM_MEM05F5: call_scm_func @GET_LOCATION params_count 1 [email protected] [email protected]: [email protected] = read_memory [email protected] size 4 virtual_protect 005F6: ret 1 [email protected]:[email protected] -= [email protected] *= 405F7: [email protected] = label @THREAD_MEMORY offset005A: [email protected] += [email protected]: ret 1 [email protected]:THREAD_MEMORYhex00 00 00 00 // [email protected]      ACTORS = 800 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected]      MARKERS = 800 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected]

Share this post


Link to post
Share on other sites
kosticn101

 

 

while true    wait 0 ms    for ZOMBIE_COUNTER = 18 TO 25 step 1        05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER ZOMBIE         if or            ZOMBIE == 0            0118:   actor ZOMBIE dead            80FB:   NOT player $PLAYER_CHAR 0 near_actor ZOMBIE radius 100.0 100.0 100.0        then                                                                                // Memory flushing            ...        end    end                                                  end

 


This should be more like:

 

for ZOMBIE_COUNTER = 18 TO 25 step 1   05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER ZOMBIE    if not ZOMBIE == 0   then       if or           0118:   actor ZOMBIE dead           80FB:   NOT player $PLAYER_CHAR 0 near_actor ZOMBIE radius 100.0 100.0 100.0       then                                                                                // Memory flushing           ...                            end   endend

 


===

MEMORY = ZOMBIE_COUNTER                                                 MEMORY += 3205F5: call_scm_func @READ_FROM_MEM params_count 1 MEMORY MARKER0164: disable_marker MARKER05F5: call_scm_func @WRITE_TO_MEM params_count 2 MEMORY ZEROER

ZOMBIE_COUNTER has value between 18 and 25, you are incrementing that value by 32 and then trying to read value from that place in thread memory, but you only have variables 18..33. If ZOMBIE_COUNTER is for example is 25, 25 + 32 = 57, what then? You should increment by 8 instead.
===

for ZOMBIE_COUNTER = 18 TO 25 step 1

Would you like to stop counting from 18 and start counting from 0 to 7? You just need to remove [email protected] -= 18 from GET_LOCATION function and then you can start counting thread memory variables from 0.
===
This is not working very well, you are not preventing script from continuing if there is no free place in memory. Something like this will work: (no, it wont work :))
===
Great mod, but zombies are running away sometimes :D.

Edited by kosticn101

Share this post


Link to post
Share on other sites
krvger

Thank you! Here is your cookie: :cookie::cookie::lol::lol:

 

BTW I used your code snippet from the previous post you've written and tried to grasp its meaning

Edited by krvger
  • Like 1

Share this post


Link to post
Share on other sites
kosticn101

I've edited the post a little bit, specifically first problem (in case that you saw old version).

 

I can send you full code if you want. If I wasn't clear somewhere ask me freely.

Edited by kosticn101
  • Like 1

Share this post


Link to post
Share on other sites
krvger

I would appreciate if you could send me the code in pm.

 

Thanks for the help again!

Share this post


Link to post
Share on other sites
kosticn101

Basically your code crashed because of

80FB:   NOT player $PLAYER_CHAR 0 near_actor ZOMBIE radius 100.0 100.0 100.0
(I don't know why, remove that line for now :D) and because you are incrementing ZOMBIE_COUNTER/MEMORY by 32 and not by 8. Fix these two things and your game wont crash.

 

And I suggested you to change this:

 

 

while true    wait 0 ms    for ZOMBIE_COUNTER = 18 TO 25 step 1        05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER ZOMBIE         if or            ZOMBIE == 0            0118:   actor ZOMBIE dead            80FB:   NOT player $PLAYER_CHAR 0 near_actor ZOMBIE radius 100.0 100.0 100.0        then                                                                                // Memory flushing            MEMORY = ZOMBIE_COUNTER                                                             MEMORY += 32            05F5: call_scm_func @READ_FROM_MEM params_count 1 MEMORY MARKER            0164: disable_marker MARKER            05F5: call_scm_func @WRITE_TO_MEM params_count 2 MEMORY ZEROER            01C2: remove_references_to_actor ZOMBIE // Like turning an actor into a random pedestrian            05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER ZEROER                                 jump @START         end    end                                                  end

 

to this:

 

 

for ZOMBIE_COUNTER = 18 TO 25 step 1   05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER ZOMBIE    if not ZOMBIE == 0   then       if// or           0118:   actor ZOMBIE dead       //    80FB:   NOT player $PLAYER_CHAR 0 near_actor ZOMBIE radius 100.0 100.0 100.0       then                                                                                // Memory flushing            MEMORY = ZOMBIE_COUNTER                                                             MEMORY += 8            05F5: call_scm_func @READ_FROM_MEM params_count 1 MEMORY MARKER            0164: disable_marker MARKER            05F5: call_scm_func @WRITE_TO_MEM params_count 2 MEMORY ZEROER            01C2: remove_references_to_actor ZOMBIE // Like turning an actor into a random pedestrian            05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER ZEROER                                 jump @START                            end   endend

 

=====================

if and  05F5: call_scm_func @PED_CHECK params_count 1 ZOMBIE    // Is actor police or mission ped  02D8: actor ZOMBIE current_weapon == 0 then
I don't think that call_scm_func works very well when combined with other conditions, maybe you should separate them.

 

I also wrote that you should use this code

 

 

for ZOMBIE_COUNTER = 18 TO 25 step 1    05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER MEMORY     // Check for used memory    if MEMORY == 0    jf continue    jump @FREE_PLACEend//this will be skipped if MEMORY == 001C2: remove_references_to_actor ZOMBIE // Like turning an actor into a random pedestrianjump @START:FREE_PLACE

 

but don't use it :D.

 

You should probably remove "answered" for now because script doesn't work 100% as expected.

=====================

Also I've tried to structure your code in a different way, but I failed and it's not working well :D. Use your code, but you can also check my version out:

 

 

... FREE_SPACE = [email protected] ...:STARTwhile true    wait 300 ms    if Player.Defined($PLAYER_CHAR)    then        FREE_SPACE = -1        for ZOMBIE_COUNTER = 18 TO 25 step 1           wait 0           05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER ZOMBIE            if NOT ZOMBIE == 0           then                if// or                    0118:   actor ZOMBIE dead                //    80FB:   NOT player $PLAYER_CHAR near_actor 0 ZOMBIE radius 100.0 100.0 100.0                then                                                                              // Memory flushing                    MEMORY = ZOMBIE_COUNTER                                                                           MEMORY += 8                    05F5: call_scm_func @READ_FROM_MEM params_count 1 MEMORY MARKER                    0164: disable_marker MARKER                    05F5: call_scm_func @WRITE_TO_MEM params_count 2 MEMORY 0                    01C2: remove_references_to_actor ZOMBIE // Like turning an actor into a random pedestrian                    05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER 0                    if FREE_SPACE == -1                    then                        FREE_SPACE = ZOMBIE_COUNTER                    end                    jump @START                 end            else                if FREE_SPACE == -1                then                    FREE_SPACE = ZOMBIE_COUNTER                end            end        end        if NOT FREE_SPACE == -1        then            0054: store_player $PLAYER_CHAR position_to PLAYER_X PLAYER_Y PLAYER_Z            if 05EF: ZOMBIE = random_actor_near_point PLAYER_X PLAYER_Y PLAYER_Z in_radius 25.0 find_next 0 pass_deads 1 //IF and SET            then                          if 05F5: call_scm_func @PED_CHECK params_count 1 ZOMBIE    // Is actor police or mission ped                then                    if 02D8: actor ZOMBIE current_weapon == 0                     then                        0209: GUN = random_int_in_ranges 259 270                        0247: request_model GUN                        038B: load_requested_models                         GUN -= 258                                        01B2: give_actor ZOMBIE weapon GUN ammo 0 // Load the weapon model before using this                        if GUN == 11                        then                            0245: set_actor ZOMBIE walk_style_to 35                         end                         01CC: actor ZOMBIE kill_player $PLAYER_CHAR                        05F5: call_scm_func @WRITE_TO_MEM params_count 2 FREE_SPACE ZOMBIE  // Write actor to non-occupied space                        0187: MARKER = create_marker_above_actor ZOMBIE                        ZOMBIE_COUNTER += 8                        05F5: call_scm_func @WRITE_TO_MEM params_count 2 FREE_SPACE MARKER  // Write its marker to another one                    end                end            end        end    endend

 

Edited by kosticn101

Share this post


Link to post
Share on other sites
krvger

Well, I got a little bit confused by this new structure, so at first it checks if is there any free space in the thread memory? Why does the "FREE_SPACE" var become -1 then? I got it that if the code is finished with checking the free space, it gets the new counter value to write it to that specific position in the thread memory.

Share this post


Link to post
Share on other sites
kosticn101

That was only my attempt to structure code little bit differently, but it's not working as I've expected. You can just fix those two/three things that cause your game to crash and continue working on your original code.

My idea was to divide code in two parts:
+ (always) cleaning up the thread memory (and at the same time finding a free space in it, if it exists)
+ (only if there is a free space in memory) getting an actor, writing to memory, and other related things.

I've decided that FREE_SPACE == -1 should mean that there is no free space in thread memory. If free space in memory was found during cleanup phase (ie. ZOMBIE was equal to 0, or I've removed a zombie from the memory and that space is now empty), then FREE_SPACE has value of a counter which is not equal to -1.

I'm resetting FREE_SPACE to -1 every time before cleanup phase because there will be leftover value from previous iteration, ie. that space in memory that was free previously, it's not free now - it's full. If free space exists, value will change and it wont be -1 anymore; if free space doesn't exist, it will stay -1.

if FREE_SPACE == -1then    FREE_SPACE = ZOMBIE_COUNTERend

Here I'm changing the value of FREE_SPACE. I could just write FREE_SPACE = ZOMBIE_COUNTER (without if) but I didn't want to change value of FREE_SPACE every time when I see a free space during a cleanup, only the first time (when FREE_SPACE was still -1).

 

But, again, it's not working correctly :D.

Edited by kosticn101

Share this post


Link to post
Share on other sites
krvger

I tested your code, what I noticed is that the marker don't disable after the actor is dead, however, I have encountered this problem before and could solve it by setting the marker variable zero and creating a condition, where it checks for the marker variable and if it is zero then and only then remove the references from the said actor.

  • Like 1

Share this post


Link to post
Share on other sites
kosticn101

If we forget for a moment that 80FB: NOT player $PLAYER_CHAR 0 near_actor ZOMBIE radius 100.0 100.0 100.0 crashes the game for unknown reasons, looks like script works? Though as far as I noticed, it wont start again if you get wasted or busted? Also I saw some zombie cops? And what happens when you don't have free space in memory and you capture a ped? It looks to me that your script is overwriting last variable in a thread memory:

 

for ZOMBIE_COUNTER = 18 TO 25 step 1    05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER MEMORY     // Check for used memory    if MEMORY == 0    then        break    end                                                  end
If free space isn't found, MEMORY will have value of 25 and script just continues. Maybe you should move your cleaning code before that and then you can do something like this:

 

for ZOMBIE_COUNTER = 18 TO 25 step 1    05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER MEMORY     // Check for used memory    if MEMORY == 0    then        break    else      //so memory isn't free and you got to the end of a loop      if NOT ZOMBIE_COUNTER == 25      else_jump @START    end                                                  end
I'm just guessing right now, I don't have access to the Vice City anymore.

 

Maybe other opcodes will work, like:

https://gtagmodding.com/opcode-database/opcode/0104/

https://gtagmodding.com/opcode-database/opcode/00FE/ (with the coords of a player)

Edited by kosticn101

Share this post


Link to post
Share on other sites
kosticn101

My guess is that result of your PED_CHECK function is actually determined by the last condition. If not [email protected] == 104 is true, then true is returned. If it's false, then false is returned. This should work:

 

//declaring variables//probably necessaryint [email protected] [email protected] and  [email protected] == 1        [email protected] < 1  [email protected] > 6  [email protected] < 97  [email protected] > 104then  //[email protected] = 1  00C5: return_trueelse  //[email protected] = 0  059A: return_falseend//[email protected] == 105F6: ret 0

 


If you use call_scm_func as a condition in a if statement, don't use if and and if or because it doesn't work together with other conditions correctly.

Edited by kosticn101

Share this post


Link to post
Share on other sites
krvger

Tried with both opcode, none of them works unfortunately :/

 

There is no opcode for return_true and return_false in VC, or at least as I know, maybe a new integer value could help, if we set it to 1 and check it with call_scm_func

 

Something like this:

05E6: [email protected] = actor [email protected] struct0085: [email protected] = [email protected]@ += [email protected] += 0x160int [email protected] [email protected] [email protected]: [email protected] = read_memory [email protected] size 2 virtual_protect 005E0: [email protected] = read_memory [email protected] size 2 virtual_protect 0if and    [email protected] == 1    [email protected] < 1    [email protected] > 6    [email protected] < 97    [email protected] > 104then    [email protected] = [email protected] == 105F6: ret 0

Tried it, doesn't seem to work

Edited by krvger

Share this post


Link to post
Share on other sites
kosticn101

Ok, then just delete those opcodes and uncomment commented lines ([email protected] = 1, [email protected] = 0, [email protected] == 1).

Yes, that's what I had in mind.

 

 

Tried with both opcode, none of them works unfortunately :/

Game crashes or they simply don't work? Edited by kosticn101

Share this post


Link to post
Share on other sites
krvger

Game crashes for unknown reason

Share this post


Link to post
Share on other sites
kosticn101

Tried it, doesn't seem to work

Hmm.. Are you sure about those memory addresses/offsets? I can't find them in the docs. If you are sure that your function is written correctly, maybe you can try to return [email protected] and then check if that value == 1 in the main part of a code - idk maybe condition flag isn't set correctly.

 

Have you separated call_scm_func from other condition?

 

if 05F5: call_scm_func @PED_CHECK params_count 1 ZOMBIE    // Is actor police or mission pedthen  if 02D8: actor ZOMBIE current_weapon == 0     then

Game crashes for unknown reason

Well it's not unknown, at least we now that it's because of those opcodes. :D Do you have scrlog installed? You can find it in the Sanny Builder folder > tools (scrlog.asi and scrlog.ini). It should show last line of a code that was executed before game crashed, check out scrlog.log file that is generated. It may be interesting to see those last lines (if log was empty). Edited by kosticn101

Share this post


Link to post
Share on other sites
krvger

 

Tried it, doesn't seem to work

Hmm.. Are you sure about those memory addresses/offsets? I can't find them in the docs. If you are sure that your function is written correctly, maybe you can try to return [email protected] and then check if that value == 1 in the main part of a code - idk maybe condition flag isn't set correctly.

 

Have you separated call_scm_func from other condition?

 

Game crashes for unknown reason

Well it's not unknown, at least we now that it's because of those opcodes. :D Do you have scrlog installed? You can find it in the Sanny Builder folder > tools. It should show last line of a code that was executed before game crashed. It may be interesting to see those last lines (if log was empty).

 

 

Yes, I'm sure about that, used them before with success and yes, I installed SCRLog, but because the game crashes, it doesn't save the log.

Share this post


Link to post
Share on other sites
kosticn101

but because the game crashes, it doesn't save the log

It's initially set to save the log (only) in such cases, but if it doesn't I've left a link for you: http://gtaforums.com/topic/892369-scrlog-locking-my-game-on-25fps/?p=1069736343

Forget about those opcodes for now, let's fix scm_func if we can.

 

 

Have you separated call_scm_func from other condition?

Edited by kosticn101

Share this post


Link to post
Share on other sites
krvger

I used your code and tested it with scrlog, (a slightly modified one) it gave me this:

 

********************************************
script zombies
Local variables dump:
1123506693 -1001831045 1092944701 4609 0 4 0 0 0 0 0 0 0 0 0 0
28024 28024
********************************************
266529274&0: [05F5] CALL
266529810&0: [05F5] CALL
266529846&0: [0012] MULT_INT_LVAR_BY_VAL
266529853&0: [05F7] GET_LABEL_POINTER -> 275279807
266529863&0: [005A] ADD_INT_LVAR_TO_INT_LVAR
266529871&0: [05F6] RET -> 275279823
266529826&0: [05E0] READ_MEMORY -> 0x0
266529838&0: [05F6] RET -> 0
266529290&0: [00D6] IF
266529294&0: [8039] NOT IS_INT_LVAR_EQUAL_TO_NUMBER // FALSE
266529301&0: [004D] GOTO_IF_FALSE
266529409&0: [0054] GET_PLAYER_COORDINATES
266529423&0: [00D6] IF
266529427&0: [05EF] FIND_ALL_RANDOM_CHARS_IN_SPHERE // TRUE -> 6.45858e-042
266529450&1: [004D] GOTO_IF_FALSE
266529457&1: [00D6] IF
266529461&0: [05F5] CALL
266529643&0: [05E6] GET_CHAR_POINTER -> 194318248
266529651&0: [0085] SET_LVAR_INT_TO_LVAR_INT
266529659&0: [000A] ADD_VAL_TO_INT_LVAR
266529666&0: [000A] ADD_VAL_TO_INT_LVAR
266529674&0: [05E0] READ_MEMORY -> 0x9
266529686&0: [05E0] READ_MEMORY -> 0x1
266529698&0: [00D6] IF
266529702&1: [0039] IS_INT_LVAR_EQUAL_TO_NUMBER // TRUE
266529709&1: [8029] NOT COMMAND_0029 // FALSE
266529716&0: [0019] IS_INT_LVAR_GREATER_THAN_NUMBER // TRUE
266529723&0: [8029] NOT COMMAND_0029 // TRUE
266529730&0: [0019] IS_INT_LVAR_GREATER_THAN_NUMBER // FALSE
266529737&0: [004D] GOTO_IF_FALSE
266529758&0: [0006] SET_LVAR_INT
266529765&0: [0039] IS_INT_LVAR_EQUAL_TO_NUMBER // FALSE
266529772&0: [05F6] RET
266529474&0: [004D] GOTO_IF_FALSE
266529615&0: [000A] ADD_VAL_TO_INT_LVAR
266529622&0: [0019] IS_INT_LVAR_GREATER_THAN_NUMBER // FALSE
266529629&0: [004D] GOTO_IF_FALSE
266529270&0: [0001] WAIT
Edited by krvger

Share this post


Link to post
Share on other sites
kosticn101

Post your full current code (or the most stable one).

I'm nearly out of ideas. :bored: I'll check it out as soon as I can.

 

Others are allowed to join the discussion as well...

Edited by kosticn101

Share this post


Link to post
Share on other sites
krvger


{$CLEO .cs}

0000: NOP

 

const

PLAYER_X = [email protected]

PLAYER_Y = [email protected]

PLAYER_Z = [email protected]

ZOMBIE = [email protected]

GUN = [email protected]

ZOMBIE_COUNTER = [email protected]

MEMORY = [email protected]

MARKER = [email protected]

end

 

var

[email protected] : float

[email protected] : float

[email protected] : float

[email protected] : int

[email protected] : int

[email protected] : int

[email protected] : int

[email protected] : int

end

 

:START

while true

wait 300 ms

if Player.Defined($PLAYER_CHAR)

then

for ZOMBIE_COUNTER = 0 TO 7 step 1

wait 0

05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER ZOMBIE

if NOT ZOMBIE == 0

then

if// or

0118: actor ZOMBIE dead

// 80FB: NOT player $PLAYER_CHAR near_actor 0 ZOMBIE radius 100.0 100.0 100.0

then // Memory flushing

MEMORY = ZOMBIE_COUNTER

MEMORY += 8

05F5: call_scm_func @READ_FROM_MEM params_count 1 MEMORY MARKER

0164: disable_marker MARKER

05F5: call_scm_func @WRITE_TO_MEM params_count 2 MEMORY 0

01C2: remove_references_to_actor ZOMBIE // Like turning an actor into a random pedestrian

05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER 0

jump @START

end

else

0054: store_player $PLAYER_CHAR position_to PLAYER_X PLAYER_Y PLAYER_Z

if 05EF: ZOMBIE = random_actor_near_point PLAYER_X PLAYER_Y PLAYER_Z in_radius 25.0 find_next 0 pass_deads 1 //IF and SET

then

if 05F5: call_scm_func @PED_CHECK params_count 1 ZOMBIE // Is actor police or mission ped

then

if 02D8: actor ZOMBIE current_weapon == 0

then

0209: GUN = random_int_in_ranges 259 270

0247: request_model GUN

038B: load_requested_models

GUN -= 258

01B2: give_actor ZOMBIE weapon GUN ammo 0 // Load the weapon model before using this

if GUN == 11

then

0245: set_actor ZOMBIE walk_style_to 35

end

01CC: actor ZOMBIE kill_player $PLAYER_CHAR

05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER ZOMBIE // Write actor to non-occupied space

0187: MARKER = create_marker_above_actor ZOMBIE

ZOMBIE_COUNTER += 8

05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER MARKER // Write its marker to another one

end

end

end

end

end

end

end

 

:PED_CHECK

05E6: [email protected] = actor [email protected] struct

0085: [email protected] = [email protected]

[email protected] += 0x5C

[email protected] += 0x160

int [email protected]

int [email protected]

int [email protected]

05E0: [email protected] = read_memory [email protected] size 2 virtual_protect 0

05E0: [email protected] = read_memory [email protected] size 2 virtual_protect 0

if and

[email protected] == 1

[email protected] < 1

[email protected] > 6

[email protected] < 97

[email protected] > 104

then

[email protected] = 1

else

[email protected] = 0

end

[email protected] == 1

05F6: ret 0

 

:WRITE_TO_MEM

05F5: call_scm_func @GET_LOCATION params_count 1 [email protected] [email protected]

05DF: write_memory [email protected] size 4 value [email protected] virtual_protect 0

05F6: ret 0

 

:READ_FROM_MEM

05F5: call_scm_func @GET_LOCATION params_count 1 [email protected] [email protected]

05E0: [email protected] = read_memory [email protected] size 4 virtual_protect 0

05F6: ret 1 [email protected]

 

:GET_LOCATION

[email protected] *= 4

05F7: [email protected] = label @THREAD_MEMORY offset

005A: [email protected] += [email protected]

05F6: ret 1 [email protected]

 

:THREAD_MEMORY

hex

00 00 00 00 // [email protected] ACTORS = 8

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected] MARKERS = 8

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

00 00 00 00 // [email protected]

end

Share this post


Link to post
Share on other sites
kosticn101

 

 

{$CLEO .cs}0000: NOP const    PLAYER_X = [email protected]    PLAYER_Y = [email protected]    PLAYER_Z = [email protected]    ZOMBIE = [email protected]    GUN = [email protected]    ZOMBIE_COUNTER = [email protected]    MEMORY = [email protected]    MARKER = [email protected] var    [email protected]  : float    [email protected]  : float    [email protected]  : float    [email protected]  : int    [email protected]  : int        [email protected]  : int    [email protected]  : int    [email protected]  : intend :STARTwhile true    wait 300 ms    if Player.Defined($PLAYER_CHAR)    then        for ZOMBIE_COUNTER = 0 TO 7 step 1           wait 0           05F5: call_scm_func @READ_FROM_MEM params_count 1 ZOMBIE_COUNTER ZOMBIE            if NOT ZOMBIE == 0           then                if //or                    0118: actor ZOMBIE dead                    //==== my guess is that zombie actually despawns and that's why game crashes.                    //==== maybe random_actor_near_point doesn't mark an actor as needed...                    //80FB: NOT player $PLAYER_CHAR near_actor 0 ZOMBIE radius 100.0 100.0 100.0                then                                                                              // Memory flushing                    MEMORY = ZOMBIE_COUNTER                                                                           MEMORY += 8                    05F5: call_scm_func @READ_FROM_MEM params_count 1 MEMORY MARKER                    0164: disable_marker MARKER                    05F5: call_scm_func @WRITE_TO_MEM params_count 2 MEMORY 0                    01C2: remove_references_to_actor ZOMBIE // Like turning an actor into a random pedestrian                    05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER 0                    jump @START                 end            else                0054: store_player $PLAYER_CHAR position_to PLAYER_X PLAYER_Y PLAYER_Z                //==== random_actor_near_point looks very choosy to me. sometimes peds are passing                //==== by and nothing is happening till you get down the road and then it works...                if 05EF: ZOMBIE = random_actor_near_point PLAYER_X PLAYER_Y PLAYER_Z in_radius 25.0 find_next 0 pass_deads 1 //IF and SET                        then                                                                                                                                                 if  05F5: call_scm_func @PED_CHECK params_count 1 ZOMBIE    // Is actor police or mission ped                                                    then                                                                                                                                                 if 02D8: actor ZOMBIE current_weapon == 0                                                                                                        then                                                                                                                                                 0209: GUN = random_int_in_ranges 259 270                                                                                                         0247: request_model GUN                                                                                                                          038B: load_requested_models                                                                                                                      GUN -= 258                                                                                                                                       01B2: give_actor ZOMBIE weapon GUN ammo 0 // Load the weapon model before using this                                                             if GUN == 11                                                                                                                                     then                                                                                                                                                 0245: set_actor ZOMBIE walk_style_to 35                                                                                                      end                            01CC: actor ZOMBIE kill_player $PLAYER_CHAR                                                                                                      05F5: call_scm_func @WRITE_TO_MEM params_count 2 ZOMBIE_COUNTER ZOMBIE  // Write actor to non-occupied space                                        0187: MARKER = create_marker_above_actor ZOMBIE                                                                                                  //ZOMBIE_COUNTER += 8 //==== not valid anymore                            MEMORY = ZOMBIE_COUNTER                                                                                   MEMORY += 8                                                                                                                           05F5: call_scm_func @WRITE_TO_MEM params_count 2 MEMORY MARKER  // Write its marker to another one                                                                                                                                           end                                 end                                                                                                                                          end                                                                                                                                          end                      end    endend :PED_CHECK05E6: [email protected] = actor [email protected] struct0085: [email protected] = [email protected]@ += [email protected] += 0x16005E0: [email protected] = read_memory [email protected] size 2 virtual_protect 005E0: [email protected] = read_memory [email protected] size 2 virtual_protect 0//==== well, my shorter way of doing this doesn't work if and    [email protected] == 1    not [email protected] == 1    not [email protected] == 2    not [email protected] == 3    not [email protected] == 4    not [email protected] == 5    not [email protected] == 6    not [email protected] == 97then    if and        not [email protected] == 98        not [email protected] == 99        not [email protected] == 100        not [email protected] == 101        not [email protected] == 102        not [email protected] == 103        not [email protected] == 104    then        [email protected] = 1    [email protected] == 105F6: ret 0 :WRITE_TO_MEM05F5: call_scm_func @GET_LOCATION params_count 1 [email protected] [email protected]: write_memory [email protected] size 4 value [email protected] virtual_protect 005F6: ret 0 :READ_FROM_MEM05F5: call_scm_func @GET_LOCATION params_count 1 [email protected] [email protected]: [email protected] = read_memory [email protected] size 4 virtual_protect 005F6: ret 1 [email protected] :[email protected] *= 405F7: [email protected] = label @THREAD_MEMORY offset005A: [email protected] += [email protected]: ret 1 [email protected] :THREAD_MEMORYhex00 00 00 00 // [email protected]      ACTORS = 800 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected]      MARKERS = 800 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected] 00 00 00 // [email protected]

 

 

Edited by kosticn101
  • Like 1

Share this post


Link to post
Share on other sites
krvger

I guess you've solved it, it works, and the zombies despawn when you're not close to them without 80FB: opcode

 

Peds sometimes run away, maybe changing pedtype could solve this or adding player as threat through 03F1: opcode?

Edited by krvger

Share this post


Link to post
Share on other sites
kosticn101

the zombies despawn when you're not close to them without 80FB: opcode

Yeah, but you still need to free that space in a thread memory? Maybe 856D: NOT actor ZOMBIE defined can help with that. Is there any other opcode to get a random actor, preferably the one that marks an actor as needed and prevents despawning (so you can use 80FB)? What if you decrease radius for 80FB and free that space before ped despawns?

 

Peds sometimes run away, maybe changing pedtype could solve this or adding player as threat through 03F1: opcode?

03F1 will influence all other peds of that type, I'm not sure that's a good idea. Try with 0291: set_actor ZOMBIE attack_when_provoked 1 (try setting value both to 0 and to 1). Other then that I don't have other ideas :whuh:.

 

There is 0350: set_actor $853 maintain_position_when_attacked 1, but that description is wrong, it's actually called SET_CHAR_STAY_IN_SAME_PLACE (at least in VC, you can try it just to be sure), which is not what you want.

 

maybe changing pedtype could solve this

Memory hacking maybe? Idk, there is no info on pedtype address on GTAModding.

Edited by kosticn101

Share this post


Link to post
Share on other sites
krvger

Found a memory address that gets the pointer to the nearest peds, it's CPed + 0x56C, going to test it soon.

 

Tried to set ped_stats to 30 to make peds psycho with 0243: set_actor ZOMBIE ped_stats_to 30, but they flee when the cops arrive and hear gunshots.

Edited by krvger

Share this post


Link to post
Share on other sites
skatefilter5

Well if they flee, try editing pedstat

Sat or set hate for the zombie to all pedtypes but zombies are in peds and they still run away still

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.


  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

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