Quantcast

Jump to content

» «
Photo

Introduction to SA Chain Game Style Save Editing - Mobile/PC

107 replies to this topic
OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#31

Posted 19 July 2014 - 05:27 PM Edited by OrionSR, 19 July 2014 - 05:30 PM.

Garage Stuffing Test - writes full vehicle directly into a garage.

{$CLEO .csi}
//grgstuf.txt

//-------------MAIN---------------
//03A4: name_thread 'GRGSTUF' 
//OSR/CG4Android: variables updated for SA Mobile


//RBR/CG37: ------------------ Garage Stuffing ------------------------

//RBR/CG37: index of save garages
//    0 - Johnson House
//    1 - Santa Maria Beach
//    2 - Rockshore West
//    3 - Fort Carson
//    4 - Verdant Meadows Garage
//    5 - Dillimore
//    6 - Prickle Pine
//    7 - Whitewood Estates
//    8 - Palomino Creek
//    9 - Redsands West
//    10 - El Corona
//    11 - Mulholland
//    12 - LS Impound
//    13 - SF Impound
//    14 - LV Impound
//    15 - Calton Heights
//    16 - Paradiso
//    17 - Doherty
//    18 - Hashbury
//    19 - Verdant Meadows Hangar

// Santa Maria Beach: Mutant FCR-900 (aqua, Virtual)
0006: 1@ = 1               //  Garage Index - Santa Maria Beach -- 'BEACSV'
0006: 2@ = 0               //  Slot Index (car 1 = index 0)
0007: 10@ = 324.5          //  X Coordinate
0007: 11@ = -1766.5        //  Y Coordinate
0007: 12@ = 4.159509       //  Z Coordinate
0006: 13@ = 0x00000000     //  unknown (4 bytes)
0006: 14@ = 0x00           //  Car Flags     
0006: 15@ = 0              //  unknown (byte)
0006: 16@ = #FCR900        //  Model ID 
0006: 17@ = #wheel_gn4     //  Mod Part (word)  // Virtual
0006: 18@ = -1             //  Mod Part (word)
0006: 19@ = -1             //  Mod Part (word)
0006: 20@ = -1             //  Mod Parts (2 words)
0006: 21@ = -1             //  Mod Parts (2 words)
0006: 22@ = -1             //  Mod Parts (2 words)
0006: 23@ = -1             //  Mod Parts (2 words)
0006: 24@ = -1             //  Mod Parts (2 words)
0006: 25@ = -1             //  Mod Parts (2 words)
0006: 26@ = 93             //  Primary Color
0006: 27@ = 93             //  Secondary Color
0006: 28@ = 0              //  Tertiary Color
0006: 29@ = 0              //  Quaternary Color
0006: 30@ = 11             //  Radio Station 
0006: 31@ = -1             //  Vehicle Variation 1
0006: 32@ = -1             //  Vehicle Variation 2
0006: 33@ = 0              //  Bomb Type
0006: 34@ = -1             //  Paintjob
0006: 35@ = 0              //  Nitrous Count
0006: 36@ = 0x00           //  Vector X
0006: 37@ = 0x9D           //  Vector Y
0006: 38@ = 0x00           //  Vector Z
0006: 39@ = 0              //  Align
0050: gosub @sub_CG_StuffCar

:CG_GarageStuffing_End
00BB: show_text_lowpriority GXT 'FESZ_LS' time 2000 flag 1  // Load Successful.
004E: end_thread 



//RBR/CG37: ------ Subroutines used by :CG_GarageStuffing ------

:sub_CG_StuffCar
//OSR/CG4Android/ Reworked to use limited local variables. 
// calculates memory addresses (340@ - 369@) from 301@ (garage index) and 302@ (slot index)
// writes car data 310@ - 339@ to memory addresses 340@ - 369@ 

// Calculate starting address of the garage's car slot
0006: 3@ = 256            // garage record size 
0006: 4@ = 64             // car slot record size 
006A: 3@ *= 1@            // garage record size *= Garage Index
006A: 4@ *= 2@            // car slot record size *= Car Slot Index
005A: 3@ += 4@            // garage offset += slot offset
000A: 3@ += 0x6BFC74      // += start of garagecar data

{
//OSR/CG4Android/ Retained for reference
// Add field offsets
000A: 340@ += 0x00          // X Coordinate
000A: 341@ += 0x04          // Y Coordinate
000A: 342@ += 0x08          // Z Coordinate
000A: 343@ += 0x0C          // unknown (4 bytes)
000A: 344@ += 0x10          // Car Flags
000A: 345@ += 0x11          // unknown (byte)
000A: 346@ += 0x12          // Model ID 
000A: 347@ += 0x14          // Mod Part (word)
000A: 348@ += 0x16          // Mod Part (word)
000A: 349@ += 0x18          // Mod Part (word)
000A: 350@ += 0x1A          // Mod Parts (2 words)
000A: 351@ += 0x1E          // Mod Parts (2 words)
000A: 352@ += 0x22          // Mod Parts (2 words)
000A: 353@ += 0x26          // Mod Parts (2 words)
000A: 354@ += 0x2A          // Mod Parts (2 words)
000A: 355@ += 0x2E          // Mod Parts (2 words)
000A: 356@ += 0x32          // Primary Color
000A: 357@ += 0x33          // Secondary Color
000A: 358@ += 0x34          // Tertiary Color
000A: 359@ += 0x35          // Quaternary Color
000A: 360@ += 0x36          // Radio Station
000A: 361@ += 0x37          // Vehicle Variation 1
000A: 362@ += 0x38          // Vehicle Variation 2
000A: 363@ += 0x39          // Bomb Type
000A: 364@ += 0x3A          // Paintjob
000A: 365@ += 0x3B          // Nitrous Count
000A: 366@ += 0x3C          // Vector X
000A: 367@ += 0x3D          // Vector Y
000A: 368@ += 0x3E          // Vector Z
000A: 369@ += 0x3F          // Align
}
// Write Car to Garage 1@, Car Slot 2@ 
0006: 5@ = 4
0DD9: write_mem_addr 3@ value 10@ size 5@ add_ib 1 protect 0    //  X Coordinate
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 11@ size 5@ add_ib 1 protect 0    //  Y Coordinate
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 12@ size 5@ add_ib 1 protect 0    //  Z Coordinate
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 13@ size 5@ add_ib 1 protect 0    //  unknown (4 bytes)
005A: 3@ += 5@
0006: 5@ = 1
0DD9: write_mem_addr 3@ value 14@ size 5@ add_ib 1 protect 0    //  Car Flags
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 15@ size 5@ add_ib 1 protect 0    //  unknown (byte)
005A: 3@ += 5@
0006: 5@ = 2
0DD9: write_mem_addr 3@ value 16@ size 5@ add_ib 1 protect 0    //  Model ID
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 17@ size 5@ add_ib 1 protect 0    //  Mod Part (word)
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 18@ size 5@ add_ib 1 protect 0    //  Mod Part (word)
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 19@ size 5@ add_ib 1 protect 0    //  Mod Part (word)
005A: 3@ += 5@
0006: 5@ = 4
0DD9: write_mem_addr 3@ value 20@ size 5@ add_ib 1 protect 0    //  Mod Parts (2 words)
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 21@ size 5@ add_ib 1 protect 0    //  Mod Parts (2 words)
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 22@ size 5@ add_ib 1 protect 0    //  Mod Parts (2 words)
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 23@ size 5@ add_ib 1 protect 0    //  Mod Parts (2 words)
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 24@ size 5@ add_ib 1 protect 0    //  Mod Parts (2 words)
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 25@ size 5@ add_ib 1 protect 0    //  Mod Parts (2 words)
005A: 3@ += 5@
0006: 5@ = 1
0DD9: write_mem_addr 3@ value 26@ size 5@ add_ib 1 protect 0    //  Primary Color
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 27@ size 5@ add_ib 1 protect 0    //  Secondary Color
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 28@ size 5@ add_ib 1 protect 0    //  Tertiary Color
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 29@ size 5@ add_ib 1 protect 0    //  Quaternary Color
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 30@ size 5@ add_ib 1 protect 0    //  Radio Station (Radio Los Santos = 6)
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 31@ size 5@ add_ib 1 protect 0    //  Vehicle Variation 1
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 32@ size 5@ add_ib 1 protect 0    //  Vehicle Variation 2
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 33@ size 5@ add_ib 1 protect 0    //  Bomb Type
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 34@ size 5@ add_ib 1 protect 0    //  Paintjob
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 35@ size 5@ add_ib 1 protect 0    //  Nitrous Count
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 36@ size 5@ add_ib 1 protect 0    //  Vector X
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 37@ size 5@ add_ib 1 protect 0    //  Vector Y
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 38@ size 5@ add_ib 1 protect 0    //  Vector Z
005A: 3@ += 5@
0DD9: write_mem_addr 3@ value 39@ size 5@ add_ib 1 protect 0    //  Align

0051: return

//RBR/CG37: ------ Subroutines used by :CG_GarageStuffing end here -------
//RBR/CG37: ------ Garage Stuffing ends here -----------------------------

hAF9Gvs.png

  • ric-013 and khsh97 like this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#32

Posted 31 July 2014 - 01:05 AM Edited by OrionSR, 31 July 2014 - 01:07 AM.

Unallocate All Car Generators

 

This script seems to be working properly. The idea here is to dump all of the cargens for a replacement set created by another part of the script, which is why this small script bothers with a gosub. Note that setting the numplate count to 0 will allow the current set to be replaced, but the orignal information remains in memory and is saved. I might want to beef that up a little and actually wipe all of the data from the numplate records.

{$CLEO .csi}
//UnallocateAllCars.txt

//-------------MAIN---------------
//03A4: name_thread 'unallo'

0001: wait 0 ms 

0050: gosub @sub_CG_Vehicles_UnallocateAll

004E: end_thread


//OSR/CG4Android: ------------------ Unallocate All Vehicles ------------------------
:sub_CG_Vehicles_UnallocateAll
0006: 0@ = 0

:sub_CG_Vehicles_UnallocateAll_Cars
0085: 1@ = 0@
0012: 1@ *= 0x20       // cargen record size
000A: 1@ += 0x9E2B68   // start of cargen structure (v105)
000A: 1@ += 0x1D       // offset to allocation byte (save offset -2)
0DD9: write_mem_addr 1@ value 0 size 1 add_ib 1 protect 0 
00D6: if 
001B:  499 > 0@
004D: jump_if_false @sub_CG_Vehicles_UnallocateAll_Plates
000A: 0@ += 1
0002: jump @sub_CG_Vehicles_UnallocateAll_Cars

:sub_CG_Vehicles_UnallocateAll_Plates
0DD9: write_mem_addr 0x9E2B5C value 0 size 4 add_ib 1 protect 0 // Set NumPlate count to 0 (v105)
0051: return
  • ric-013 and khsh97 like this

ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union
  • Contribution Award [Mods]
    Helpfulness Awards [Mods]

#33

Posted 31 July 2014 - 03:21 PM

here's the source script of my Teleport_to_Marker cleo script
would be nice if you port it to mobile mod

It's a 6 year old script of me, not really different to the decompiled one
there i kept the version entry of sannybuilder, but it's useless and new sannybuilder ignore it

go to main menu and then to the map
set first the red marker in the map then go back into game
press Y X to teleport to marker

 
//{$VERSION 3.1.0027}
{$CLEO .cs}
:Teleport_to_Marker
thread 'TPIN' 
5@ =  0  // Author: [email protected]

:Tp2mark_01
0001: wait 0 ms 
if 
0256:   player $PLAYER_CHAR defined 
jf @Tp2mark_01 
if
03EE:   player $PLAYER_CHAR controllable   
jf @Tp2mark_01
if
0AB0:   key_pressed 89  
jf @Tp2mark_03
5@ =  1
33@ =  0

:Tp2mark_03
if  and
5@ ==  1
0AB0:   key_pressed 88  
jf @Tp2mark_06
5@ =  0
jump @Tp2mark_08

:Tp2mark_06
if
5@ ==  1  
jf @Tp2mark_01
if
33@ >  5000  
jf @Tp2mark_01
5@ =  0
jump @Tp2mark_01

:Tp2mark_08
0172: 4@ = actor $PLAYER_ACTOR z_angle
0AB6: store_target_marker_coords_to 0@ 1@ 2@
0169: set_fade_color  0  0  0
016A: fade  0 ()  500 ms
0001: wait  500 ms
01B4: set_player $PLAYER_CHAR frozen_state  0 (frozen)
04BB: select_interior  0  // select render area
04FA: reset_interior_colors  0
057E: make_radar_grey  0
04E4: REQUEST_COLLISION_at  0@  1@
03CB: set_camera  0@  1@  2@
if
0256:   player $PLAYER_CHAR defined
jf @Tp2mark_012
0860: link_actor $PLAYER_ACTOR to_interior  0 
00A1: put_actor $PLAYER_ACTOR at  0@  1@  -100.0
0173: set_actor $PLAYER_ACTOR z_angle_to  4@

:Tp2mark_012
wait  0
if
0256:   player $PLAYER_CHAR defined
jf @Tp2mark_012
0001: wait  1500 ms
016A: fade  1 (back)  1000 ms

:Tp2mark_013
if
016B:   fading
jf @Tp2mark_014
wait  0
jump @Tp2mark_013

:Tp2mark_014
wait  0
if
0256:   player $PLAYER_CHAR defined
jf @Tp2mark_014
01B4: set_player $PLAYER_CHAR frozen_state  1 (unfrozen)
0373: set_camera_directly_behind_player
02EB: restore_camera_with_jumpcut
jump @Tp2mark_01
  • ric-013 likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#34

Posted 31 July 2014 - 05:29 PM Edited by OrionSR, 31 July 2014 - 05:30 PM.

Thanks, ZAZ. Below is a working port to SA Mobile, but it's still relatively untested. It's specific to v105 due to differences in the static addresses of the memory locations and will end if used on the wrong version rather than cause unexpected problems. I hope to patch things with a constants table as new information is available. My next goal is to get a working Z swipe pattern to trigger the script - hence the name; z2mark. And yes, this is a nod to the original author. Thanks again.

 

Z2mark for SA Mobile version 1.05

{$CLEO .csa}
:Teleport_to_Marker
03A4: name_thread 'Z2MARK' 
//Author: [email protected]
//OSR/CG4Android: Adapted for CleoA by OrionSR
//z2mark.105a.txt

//    go to main menu and then to the map
//    set first the red marker in the map then go back into game
//    press toughpoints 6 7 to teleport to marker
//    remove marker to prevent teleporting accidentally

:Z2mark_00
0DD6: 7@ = get_game_version
00D6: if 
8039:   not 7@ == 7 // SA Mobile v1.05
004D: jump_if_false @Z2mark_01 
004E: end_thread 

:Z2mark_01
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined 
004D: jump_if_false @Z2mark_01 
00D6: if 
03EE:   player $PLAYER_CHAR controllable 
004D: jump_if_false @Z2mark_01 
00D6: if and 
00E1:   key_pressed 3 touch_point 6 // center-bottom
00E1:   key_pressed 3 touch_point 7 // right-top 
004D: jump_if_false @Z2mark_01

0DD8: 5@ = read_mem_addr 0x5FD8D0 size 2 add_ib 1 // read marker index
00D6: if 
8039:   not 5@ == 0    // prevent teleport if marker is removed 
004D: jump_if_false @Z2mark_01 
0012: 5@ *= 0x28       // marker record size
000A: 5@ += 0x97362C   // start of marker structure
000A: 5@ += 0x8        // offset to X coord
0DD8: 0@ = read_mem_addr 5@ size 4 add_ib 1 // read X coord
000A: 5@ += 0x4        // offset to Y coord
0DD8: 1@ = read_mem_addr 5@ size 4 add_ib 1 // read Y coord

//ZAZ's original codes start here
:Z2mark_08
0172: 4@ = actor $PLAYER_ACTOR z_angle
//0AB6: store_target_marker_coords_to 0@ 1@ 2@ //0AB6: not in CleoA
0169: set_fade_color  0  0  0
016A: fade  0 ()  500 ms
0001: wait 500 ms
01B4: set_player $PLAYER_CHAR frozen_state  0 (frozen)
04BB: select_interior  0  // select render area
04FA: reset_interior_colors  0
057E: make_radar_grey  0
04E4: REQUEST_COLLISION_at  0@  1@
03CB: set_camera  0@  1@  2@
00D6: if 
0256:   player $PLAYER_CHAR defined
004D: jump_if_false @Z2mark_012
0860: link_actor $PLAYER_ACTOR to_interior  0 
00A1: put_actor $PLAYER_ACTOR at  0@  1@  -100.0
0173: set_actor $PLAYER_ACTOR z_angle_to  4@

:Z2mark_012
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined
004D: jump_if_false jf @Z2mark_012
0001: wait 1500 ms
016A: fade  1 (back)  1000 ms

:Z2mark_013
00D6: if 
016B:   fading 
004D: jump_if_false @Z2mark_014
0001: wait 0 ms 
0002: jump @Z2mark_013

:Z2mark_014
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined
004D: jump_if_false @Z2mark_014
01B4: set_player $PLAYER_CHAR frozen_state  1 (unfrozen)
0373: set_camera_directly_behind_player
02EB: restore_camera_with_jumpcut
0002: jump @Z2mark_01
  • khsh97 likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#35

Posted 01 August 2014 - 08:19 PM Edited by OrionSR, 01 August 2014 - 08:39 PM.

Teleport 2marker script has been updated

 

Changes:

Invokable from the CleoA menu.

Works with any-version thanks to Markuza97.

Can be pre-loaded to warp when next marker is placed.

Should work on maps without any icons.

Updated codes to current SASCM.ini format.

Added variable table (old habits...)

 {$CLEO .csi}  // SASCM.ini 14.12.2013
//2marker.txt

03A4: name_thread '2MARKER' 
//Author: [email protected]
//OSR/CG4Android: Adapted for CleoA by OrionSR
//OSR/CG4Android: Any-version address codes by Markuza97

//    go to the map and set the red marker
//    invoke the 2marker script from the CleoA menu
//    or pre-load the script and then set the marker

{
//-----------------------------------------------------
    0@, X coordinate
    1@, Y coordinate
    2@, Z coordinate
    3@, icon ID
    4@, angle
    5@, marker index calcs to read addresses
    6@, start of marker structure
    7@, marker index address
//-----------------------------------------------------
}
// Markuza97's any-version address codes - read once
0DD0: 6@ = get_label_addr @_ZN6CRadar13ms_RadarTraceE
0DD1: 6@ = get_func_addr_by_cstr_name 6@ // start of marker structure
0DD0: 7@ = get_label_addr @gMobileMenu   
0DD1: 7@ = get_func_addr_by_cstr_name 7@ // start of... menu data?
000A: 7@ += 0x48 // offset to marker index

:2marker_01
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined 
004D: jump_if_false @2marker_01 
00D6: if 
03EE:   player $PLAYER_CHAR controllable 
004D: jump_if_false @2marker_01 

//ZAZ/0AB6: store_target_marker_coords_to 0@ 1@ 2@ //0AB6: not in CleoA
{
//OSR/v1.05 specific addresses
0DD8: 5@ = read_mem_addr 0x5FD8D0 size 2 add_ib 1 // read marker index
0012: 5@ *= 0x28     // marker record size
000A: 5@ += 0x97362C // start of marker structure
000A: 5@ += 0x8      // offset to X coord
0DD8: 0@ = read_mem_addr 5@ size 4 add_ib 1 // read X coord
000A: 5@ += 0x4      // offset to Y coord
0DD8: 1@ = read_mem_addr 5@ size 4 add_ib 1 // read Y coord
000A: 5@ += 0x18     // offset to icon ID
0DD8: 3@ = read_mem_addr 5@ size 1 add_ib 1 // read icon ID
00D6: if 
0039:   3@ == 41     // prevent teleport if not marker id 
004D: jump_if_false @2marker_15 
}

// Markuza97's any-version address codes
0DD8: 5@ = read_mem_addr 7@ size 2 add_ib 0 // read marker index
0012: 5@ *= 0x28  // marker record size
000A: 5@ += 6@    // start of marker structure
000A: 5@ += 0x8   // offset to X coord
0DD8: 0@ = read_mem_addr 5@ size 4 add_ib 0 // read X coord
000A: 5@ += 0x4   // offset to Y coord
0DD8: 1@ = read_mem_addr 5@ size 4 add_ib 0 // read Y coord
000A: 5@ += 0x18  // offset to icon ID
0DD8: 3@ = read_mem_addr 5@ size 1 add_ib 0 // read icon ID
00D6: if 
0039:   3@ == 41  // prevent teleport if not marker id 
004D: jump_if_false @2marker_01      // pre-loads teleport for next marker
//004D: jump_if_false @2marker_015   // to end_thread


//ZAZ's original codes start here
//OSR/ updated to SASCM.ini 14.12.2013
//:2marker_08
0172: 4@ = actor $PLAYER_ACTOR Z_angle 
0169: set_fade_color_RGB 0 0 0 
016A: fade 0 time 500 
0001: wait 500 ms 
01B4: set_player $PLAYER_CHAR can_move 0 
04BB: select_interior 0 
04FA: reset_sky_colors_with_fade 0 
057E: set_radar_grey 0 
04E4: refresh_game_renderer_at 0@ 1@ 
03CB: set_rendering_origin_at 0@ 1@ 2@ 
00D6: if 
0256:   player $PLAYER_CHAR defined 
004D: jump_if_false @2marker_012
0860: link_actor $PLAYER_ACTOR to_interior 0 
00A1: put_actor $PLAYER_ACTOR at 0@ 1@ -100.0 
0173: set_actor $PLAYER_ACTOR Z_angle_to 4@ 

:2marker_012
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined
004D: jump_if_false jf @2marker_012
0001: wait 1500 ms
016A: fade 1 time 1000 

:2marker_013
00D6: if 
016B:   fading 
004D: jump_if_false @2marker_014
0001: wait 0 ms 
0002: jump @2marker_013

:2marker_014
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined
004D: jump_if_false @2marker_014
01B4: set_player $PLAYER_CHAR can_move 1 
0373: set_camera_directly_behind_player 
02EB: restore_camera_with_jumpcut 

:2marker_015
004E: end_thread 


// Markuza97's magic hex codes
:gMobileMenu
hex
"gMobileMenu" 00
end

:_ZN6CRadar13ms_RadarTraceE
hex
"_ZN6CRadar13ms_RadarTraceE" 00
end
  • ric-013 and khsh97 like this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#36

Posted 02 August 2014 - 09:21 AM Edited by OrionSR, 08 August 2014 - 03:18 PM.

HoldRadar.2Marker

 

Changes:

Runs in background as a .csa script.

Triggered by holding radar widget for 2 seconds only if the map marker is set.

Releasing the widget during the half second fade out will bring up the pause menu.

Removing the marker will prevent teleportation.

CJ will warp to the new location if the marker is moved during the pause.

Coordinate calculations moved to subroutine.

Camera zooms during fade in to provide context of surroundings.

 

Issues:

Need to test and modify for aircraft. Expectation is that teleported aircraft should spawn with sufficient altitude and with engines running.

 {$CLEO .csa}  // SASCM.ini 14.12.2013
//holdradar.2marker.txt

03A4: name_thread '2MARKER' 
//Author: [email protected]
//OSR/CG4Android: Adapted for CleoA by OrionSR
//OSR/CG4Android: Any-version address codes by Markuza97

//    go to the map and set the red marker
//    hold radar widget for 2 seconds to warp to the marker

{
//-----------------------------------------------------
    0@, X coordinate
    1@, Y coordinate
    2@, Z coordinate
    3@, icon ID
    4@, angle
    5@, marker index calcs to read addresses
    6@, start of marker structure
    7@, marker index address
//-----------------------------------------------------
}
// Markuza97's any-version address codes - read once
0DD0: 6@ = get_label_addr @_ZN6CRadar13ms_RadarTraceE
0DD1: 6@ = get_func_addr_by_cstr_name 6@ // start of marker structure
0DD0: 7@ = get_label_addr @gMobileMenu   
0DD1: 7@ = get_func_addr_by_cstr_name 7@ // start of... menu data?
000A: 7@ += 0x48 // offset to marker index

:2marker_01
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined 
004D: jump_if_false @2marker_01 
00D6: if 
03EE:   player $PLAYER_CHAR controllable 

0001: wait 0 ms 
00D6: if 
0A51:   is_widget_pressed 160 //radar widget
004D: jump_if_false @2marker_01 
0001: wait 2000 ms
00D6: if 
0A51:   is_widget_pressed 160 //radar widget
004D: jump_if_false @2marker_01 

0050: gosub @sub_read_marker_X_Y_ID // to 0@ 1@ 3@
00D6: if 
8039:   not 3@ == 41  // prevent teleport if not marker id 
004D: jump_if_false @2marker_08    
0001: wait 1000 ms
0002: jump @2marker_01

//ZAZ's original codes start here
//OSR/ updated to SASCM.ini 14.12.2013
:2marker_08
0172: 4@ = actor $PLAYER_ACTOR Z_angle 
0169: set_fade_color_RGB 0 0 0 
016A: fade 0 time 500 
0001: wait 500 ms 
01B4: set_player $PLAYER_CHAR can_move 0 
00D6: if 
0256:   player $PLAYER_CHAR defined 
004D: jump_if_false @2marker_012

0050: gosub @sub_read_marker_X_Y_ID // to 0@ 1@ 3@
00D6: if 
0039:   3@ == 41  // prevent teleport if not marker id 
004D: jump_if_false @2marker_012    
04BB: select_interior 0 
04FA: reset_sky_colors_with_fade 0 
057E: set_radar_grey 0 
04E4: refresh_game_renderer_at 0@ 1@ 
03CB: set_rendering_origin_at 0@ 1@ 2@ 
0860: link_actor $PLAYER_ACTOR to_interior 0 
00A1: put_actor $PLAYER_ACTOR at 0@ 1@ -100.0 
0173: set_actor $PLAYER_ACTOR Z_angle_to 4@ 
0373: set_camera_directly_behind_player 
02EB: restore_camera_with_jumpcut 

:2marker_012
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined
004D: jump_if_false jf @2marker_012
0001: wait 1500 ms
0922: set_camera_zoom_from 140.0 to 100.0 timelimit 1000 smooth_transition 0 
016A: fade 1 time 1000 

:2marker_013
00D6: if 
016B:   fading 
004D: jump_if_false @2marker_014
0001: wait 0 ms 
0002: jump @2marker_013

:2marker_014
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined
004D: jump_if_false @2marker_014
01B4: set_player $PLAYER_CHAR can_move 1 

:2marker_015
//004E: end_thread 
0002: jump @2marker_01

:sub_read_marker_X_Y_ID
0006: 2@ = 0      // explicit Z for rendering origin
0DD8: 5@ = read_mem_addr 7@ size 2 add_ib 0 // read marker index
0012: 5@ *= 0x28  // marker record size
000A: 5@ += 6@    // start of marker structure
000A: 5@ += 0x8   // offset to X coord
0DD8: 0@ = read_mem_addr 5@ size 4 add_ib 0 // read X coord
000A: 5@ += 0x4   // offset to Y coord
0DD8: 1@ = read_mem_addr 5@ size 4 add_ib 0 // read Y coord
000A: 5@ += 0x18  // offset to icon ID
0DD8: 3@ = read_mem_addr 5@ size 1 add_ib 0 // read icon ID
0051: return 


// Markuza97's magic hex codes
:gMobileMenu
hex
"gMobileMenu" 00
end

:_ZN6CRadar13ms_RadarTraceE
hex
"_ZN6CRadar13ms_RadarTraceE" 00
end
  • ric-013 and khsh97 like this

kevinwilliszjs
  • kevinwilliszjs

    Player Hater

  • Members
  • Joined: 20 May 2014
  • China

#37

Posted 12 August 2014 - 09:44 AM

great master

 

 

could you please give me a list of all the opcode can used by Android's cleo?
thank you very much!

kevinwilliszjs
  • kevinwilliszjs

    Player Hater

  • Members
  • Joined: 20 May 2014
  • China

#38

Posted 12 August 2014 - 09:54 AM

and the other thing could the Android cleo use this opcode: “ 0AB6: store_target_marker_coords_to 0@ 1@ 2@ ” 

 

i used in ios main file it's not work,ios can't use cleo,or it can use some opcode like read_mem or wirte_mem opcode. with this opcode can used the same function like 0ab6. 

Am I right?


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#39

Posted 12 August 2014 - 05:45 PM

Nope. Opcode 0AB6 is a Cleo3 command and was used in ZAZ's original script, but it's not available in CleoA.

 

The easiest way to get a mostly complete list of opcodes is using Sanny's Opcode Search IDE Tool. Setting the editor mode in the bottom right corner of the screen will set Sanny to display/use the appropriate opcodes for that version. The code list below might not be completely accurate but should give you the basic idea.

 

Opcode range:

0000: - 0A4E: standard opcodes usually available in most SA versions.

0A51: - 0A8D: SA Mobile opcodes

0A8C: - 0ABF: Cleo3 library

0AC0: - 0B16: Cleo4 library (includes Cleo3)

0DD0: - 0DE3: CleoA library

8???: logical NOT operations of 0???:

 

CleoA opcodes in the format required by SA Mobile's SASCM.ini. These lines must be added to be used in Sanny and won't show up in the Opcode Search tool.

0DD0=2,%1d% = get_label_addr %2p% ; android
0DD1=2,%1d% = get_func_addr_by_cstr_name %2d% ; android
0DD2=1,context_call_func %1d% ; android
0DD3=2,context_set_reg %1d% value %2d% ; android
0DD4=2,%1d% = context_get_reg %2d% ; android
0DD6=1,%1d% = get_game_version ; android
0DD7=1,%1d% = get_image_base ; android
0DD8=4,%1d% = read_mem_addr %2d% size %3d% add_ib %4d% ; android
0DD9=5,write_mem_addr %1d% value %2d% size %3d% add_ib %4d% protect %5d% ; android
0DDC=2,set_mutex_var %1d% to %2d% ; android
0DDD=2,%1d% = get_mutex_var %2d% ; android
0DE0=3,%1d% = get_touch_point_state %2d% mintime %3d% ; android
0DE1=5,%1d% = get_touch_slide_state from %2d% to %3d% mintime %4d% maxtime %5d% ; android
0DE2=1,%1d% = get_menu_button_state ; read opcode info before using ; android
0DE3=2,%1d% = get_menu_button_pressed mintime %2d% ; read opcode info before using ; android
  • ric-013 likes this

kevinwilliszjs
  • kevinwilliszjs

    Player Hater

  • Members
  • Joined: 20 May 2014
  • China

#40

Posted 14 August 2014 - 12:41 AM Edited by kevinwilliszjs, 14 August 2014 - 12:45 AM.

 

Nope. Opcode 0AB6 is a Cleo3 command and was used in ZAZ's original script, but it's not available in CleoA.

 

The easiest way to get a mostly complete list of opcodes is using Sanny's Opcode Search IDE Tool. Setting the editor mode in the bottom right corner of the screen will set Sanny to display/use the appropriate opcodes for that version. The code list below might not be completely accurate but should give you the basic idea.

 

Opcode range:

0000: - 0A4E: standard opcodes usually available in most SA versions.

0A51: - 0A8D: SA Mobile opcodes

0A8C: - 0ABF: Cleo3 library

0AC0: - 0B16: Cleo4 library (includes Cleo3)

0DD0: - 0DE3: CleoA library

8???: logical NOT operations of 0???:

 

CleoA opcodes in the format required by SA Mobile's SASCM.ini. These lines must be added to be used in Sanny and won't show up in the Opcode Search tool.

0DD0=2,%1d% = get_label_addr %2p% ; android
0DD1=2,%1d% = get_func_addr_by_cstr_name %2d% ; android
0DD2=1,context_call_func %1d% ; android
0DD3=2,context_set_reg %1d% value %2d% ; android
0DD4=2,%1d% = context_get_reg %2d% ; android
0DD6=1,%1d% = get_game_version ; android
0DD7=1,%1d% = get_image_base ; android
0DD8=4,%1d% = read_mem_addr %2d% size %3d% add_ib %4d% ; android
0DD9=5,write_mem_addr %1d% value %2d% size %3d% add_ib %4d% protect %5d% ; android
0DDC=2,set_mutex_var %1d% to %2d% ; android
0DDD=2,%1d% = get_mutex_var %2d% ; android
0DE0=3,%1d% = get_touch_point_state %2d% mintime %3d% ; android
0DE1=5,%1d% = get_touch_slide_state from %2d% to %3d% mintime %4d% maxtime %5d% ; android
0DE2=1,%1d% = get_menu_button_state ; read opcode info before using ; android
0DE3=2,%1d% = get_menu_button_pressed mintime %2d% ; read opcode info before using ; android

 

 

what is cleoa? cleo for Android?

thanks i got it !


kevinwilliszjs
  • kevinwilliszjs

    Player Hater

  • Members
  • Joined: 20 May 2014
  • China

#41

Posted 16 August 2014 - 05:02 PM

great master

 

 

i have another problem ,the 00e1 opcode in the ios main file.
i know this opcode in cleoA is “00E1: key_pressed 3 touch_point 6” and used to judgement which touch_point is pressed,but in the main file is “00E1:   player 0 pressed_key 8” ? what is this opcode uesed in ios main file? in mobile is use 0a51 or 0a52 to judgement which button is pressed,why also use the 00e1?
 
i find to parameters of this opcode “player 0 pressed_key” and “player 1 pressed_key”,does it mean the dafult player press some key or player 1 press some key?
 
and what is the key mean?does it mean like Virtual key codes in cleo3? but in mobile has the Virtual key codes?
 
 
thank you very much!!

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#42

Posted 16 August 2014 - 08:04 PM Edited by OrionSR, 16 August 2014 - 08:06 PM.

great master

Thank you. In my culture (west coast US) this greeting is a bit too formal. Please feel free to use greetings that indicate we are communicating with equal status.

 

I am very unfamiliar with Android devices and their controls. I've been working with limited examples but have had some success with 00E1:. See the First Cleo Script post #7 for a complete test code.

:Top
0001: wait 0 ms

00D6: if and 
00E1:   key_pressed 3 touch_point 3
00E1:   key_pressed 3 touch_point 4 
004D: jump_if_false @Top

When I compiled this the first time I couldn't get it to work until I looked at the picture of the touchpoints posted in the opening post of the Cleo for Android topic. The touchpoints are ordered from top to bottom, left to right, so:

1 - 4 - 7
2 - 5 - 8
3 - 6 - 9

So when I pressed center-top and left-bottom the script finally triggered. But now when I'm looking at the CleoA documentation it seems the touchpoint described are for the new CleoA opcodes, so... it seemed to work properly. The only other user control I've used is the widget checks in the later teleport scripts. I borrowed those codes directly from Markuza97 and haven't tried to adapt them for other uses.

 

00E1: - Most of the words don't matter except to make the script easier to read and understand. They are inserted by Sanny when decompiling and discarded when compiling. You can change the words in SASCM.ini for SA Mobile and when you decompile the new text will be displayed. In the example below, all of these lines will compile to exactly the same thing.

00E1:   key_pressed 3 touch_point 6
00E1:   player 3 pressed_key 6
00E1:   glitch 3 hardcode 6
00E1:   apple 3 banana 6
00E1:   3 6

Sanny's help documentation contains useful information on what the key press values are for PC, but I have no idea how that translates to Mobile. When I look at examples of 00E1: in the scripts of both versions I see that often widget checks have been added in addition to the key press checks. 00E1: is a standard opcode available in all versions, but it probably works a little differently on mobile.

 

I'm pretty sure that on PC, player 0 is standard and player 1 is the 2nd player option originally in the PS2 version and available with mods on PC. But on Mobile I was using player (key_pressed) 3?  Yes, very confusing.

 

Sometimes the words aren't as descriptive as they could be. My thought is maybe "controller" could substitute for player/key_pressed. Then on PC it'd be controller 0 and 1 for player 1 and 2, and maybe on Mobile the touchpoint screen can be considered a separate controller, controller 3. Maybe. I'd have to see how the description holds out in a wider context.

 

My suggestion: Keep looking for more information. I don't have the answers. If you can't find a good source of information then gather everything you can find and post it in it's own topic and ask for help filling in the missing pieces as you continue your research and update the documentation.

  • ric-013 and Markuza like this

kevinwilliszjs
  • kevinwilliszjs

    Player Hater

  • Members
  • Joined: 20 May 2014
  • China

#43

Posted 17 August 2014 - 02:15 AM

 

great master

Thank you. In my culture (west coast US) this greeting is a bit too formal. Please feel free to use greetings that indicate we are communicating with equal status.

 

I am very unfamiliar with Android devices and their controls. I've been working with limited examples but have had some success with 00E1:. See the First Cleo Script post #7 for a complete test code.

:Top
0001: wait 0 ms

00D6: if and 
00E1:   key_pressed 3 touch_point 3
00E1:   key_pressed 3 touch_point 4 
004D: jump_if_false @Top

When I compiled this the first time I couldn't get it to work until I looked at the picture of the touchpoints posted in the opening post of the Cleo for Android topic. The touchpoints are ordered from top to bottom, left to right, so:

1 - 4 - 7
2 - 5 - 8
3 - 6 - 9

So when I pressed center-top and left-bottom the script finally triggered. But now when I'm looking at the CleoA documentation it seems the touchpoint described are for the new CleoA opcodes, so... it seemed to work properly. The only other user control I've used is the widget checks in the later teleport scripts. I borrowed those codes directly from Markuza97 and haven't tried to adapt them for other uses.

 

00E1: - Most of the words don't matter except to make the script easier to read and understand. They are inserted by Sanny when decompiling and discarded when compiling. You can change the words in SASCM.ini for SA Mobile and when you decompile the new text will be displayed. In the example below, all of these lines will compile to exactly the same thing.

00E1:   key_pressed 3 touch_point 6
00E1:   player 3 pressed_key 6
00E1:   glitch 3 hardcode 6
00E1:   apple 3 banana 6
00E1:   3 6

Sanny's help documentation contains useful information on what the key press values are for PC, but I have no idea how that translates to Mobile. When I look at examples of 00E1: in the scripts of both versions I see that often widget checks have been added in addition to the key press checks. 00E1: is a standard opcode available in all versions, but it probably works a little differently on mobile.

 

I'm pretty sure that on PC, player 0 is standard and player 1 is the 2nd player option originally in the PS2 version and available with mods on PC. But on Mobile I was using player (key_pressed) 3?  Yes, very confusing.

 

Sometimes the words aren't as descriptive as they could be. My thought is maybe "controller" could substitute for player/key_pressed. Then on PC it'd be controller 0 and 1 for player 1 and 2, and maybe on Mobile the touchpoint screen can be considered a separate controller, controller 3. Maybe. I'd have to see how the description holds out in a wider context.

 

My suggestion: Keep looking for more information. I don't have the answers. If you can't find a good source of information then gather everything you can find and post it in it's own topic and ask for help filling in the missing pieces as you continue your research and update the documentation.

 

 

 

thanks


kevinwilliszjs
  • kevinwilliszjs

    Player Hater

  • Members
  • Joined: 20 May 2014
  • China

#44

Posted 21 August 2014 - 03:05 AM

could you please give me a course of how to use mobile widget button?

 

i can only use 0a51 0a52, how to use the other widget ?

like 0a53 0a54 0a5a 0a5b 0a5d 0a5e 0a60 - 0a64?

 

thank you very much

 

and i test some widget button id but not the all widget id ,do you have the all widget id list? if you have please give me,thanks


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#45

Posted 21 August 2014 - 06:06 PM Edited by OrionSR, 21 August 2014 - 08:43 PM.

No, I'm sorry. I know very little about the controls for SA Mobile. My expertise is in save editing on PC and PS2 and I was trying to apply these strategies to SA Mobile. Usually these codes run with little input, but sometimes we need a testing tool, like the teleport code, so I figured out just enough to get the touchpoints and one widget working.based on other examples.

 

If I wanted to learn more about widgets and couldn't find current documentation I would experiment with examples from the main script. I may also learn something by comparing the SA Mobile scripts with scripts from PC to see how things have changed. I would recommend using PCv1 scripts for a baseline.

 

Widget ID script by Markuza97.


kevinwilliszjs
  • kevinwilliszjs

    Player Hater

  • Members
  • Joined: 20 May 2014
  • China

#46

Posted 22 August 2014 - 02:26 AM

thanks  :pp  :pp


ric-013
  • ric-013

    Casual Lurker

  • Members
  • Joined: 24 Nov 2006
  • None

#47

Posted 01 October 2014 - 05:00 PM Edited by ric-013, 02 October 2014 - 01:57 PM.

This topic is open to everyone. Thanks for waiting.
 
Please keep in mind that a lot of the conversation is missing and I'll need to fill in some missing pieces and add clarification.
 

i rencently got GTA SA on my android tablet and started to do some save edits on my own and looked for a way to learn CLEO... this project seemed just perfect !

 
i got some modding skills, but ill be a bit confused for awhile ...  decompiled C is what im used to script wise ( gta 4 ) and i did my share of hex editing ( ps2 cheat-device ) thoses are my only 2 modding universe so far !!!
to me CLEO looks like a big mix of the 2 universes ( based on OrionSR examples ) and get me really confused at some points.
 
so far i feel i miss lots of basic info's about common known stuff and i need to understand the script format used.
 
note: im currently reading this tutorial 
 
i just need the freetime to read info's and for my brain to make sense of all this.
 
ill eventually post scripts examples and ask for dumb questions on how to do things LOL, but until then i can do some testing on my freetime.
 
BTW, since i knew OrionSR from ps2 cheat-creation days, i sent him PM's !
the conversation was very informative...
he also said that many info's we shared in PM should have been asked in topic, for others who seek info's.
 
so here a trimmed down version of our conversation ... OrionSR replies are in quotes.
 
--------------------------------------------------------------------------------------------------------------------------------------------------------------
 
intro:
Dear OrionSR , i got a few simple CLEO script questions .
ric-013.
 
 
- can i create variables ? or must i absolutely use globals ones ?

You cannot create variables. Cleo provides easy access to scm (main.scm) scripting that is executed by the interpreter. Sanny doesn't really compile an actually program. It compiles a text script into a series of opcodes and hex values that can be hooked into the game engine. Rule of thumb, don't try to use global variables in any way other than their original purpose, or try to invent new custom variable names. CleoA scripts are  given a limited number of local variables. 0@ to 39@ (?) and  a couple of timers. Custom missions in can use over 1000 local variables, but they aren't available for CleoA.

 

All variables are the same. 32 bits you can play with any way you want. If you set it as a float then be damn sure to use the float operations to work with it. I think technically all the dwords are signed, by definition or something, but you can try to use them any way you want. Most of the time you'll end up stuck with whatever the game requires for input in the long run anyway. It's weird, you'll get the hang of it once you scale back your expectations a little.
 
The list of global variables is something like $2 through $10000 or so. Some of the PC variables have been assigned common names so they are easier to work with, but on Mobile I think the list is limited to $Player_Character, $Player_Actor, and $On_Mission, We could transpose more custom variable names for SA mobile so we could use the same variable names on PC and Mobile even though the variable numbers are different. Checkout the CustomVariable.ini in Sanny's data\sa folder.

 

- signed dword / int's ? 

 

Signed integers (int) can be negative; the highest bit (for dwords it's the 32nd bit, bit 31) is used to signify negative instead of the next power of two. Unsigned integers (uint) use all the bits as positive values, so the numbers can count twice as high. In SA you'd better figure that your variables are both. You can exploit the advantages of both (setting a uint to -1 maxes out the value no matter the size of the variable) but in the end you must provide the game with the input it expects.

 

- what is the difference between normal cleo opcodes and widget ones ?


Widgets are those buttons they put on the screen for mobile users to use as controls. There are a whole set of new opcodes to manage them. The radar map works as a widget too.

Everything I know about widgets is in topic. You'll probably pass me in most of this stuff fairly quickly just by trying.

 

- can i create nested fonctions to call upon ?

 

You can create gosubs, but they don't really work as functions as you don't really pass along input and get output back, so, locals are all hard coded and all. But it does provide a useful strategy for copy and paste of useful... subroutines if an accurate enough description I guess. And everything needs to be together in the same script, for the most part.

There is a lot of higher level programming options (WHILE, FOR) available through Sanny. My examples are almost always in the most raw format possible -- what you'd get if you decompiled the script with the show opcode option. In the end though it all get's compiled in that primitive format I usually use.
 
here's a hypothetical example :
0@ = myfunction(1@);
 
In this example myfunction() doesn't know or care about 0@ and 1@. It has it's own independent variables, one of which gets passed to the function by to 1@ argument. When the function has performed its... function, it passes it's result back to the calling routine into 0@.  myfunction() doesn't even need to be part of my script. I could put it in a library of other functions and include() that library in the header of my program.
 
Here another pseudo-code example (note the indent instead of code tags) for SA.
:Main // a colon at the start marks a label, a destination for a jump or a gosub
gosub @sub_MySub
end_thread

:sub_MySub
print_text 'BEEFY'
return // returns control just after the gosub that calls it.
The order of execution will be, gosub, print_text, return. end_thread. Anyway, this seems to be how you are using your functions, and is how I like to build my script.

 

- what is FXT ?

 

FXT is a modding strategy for getting the game to display text and numbers strings that aren't encoded in the data files. You can either make a new fxt for the strings or put them in an existing *.fxt file from another mod. 

 

- im highly interrested in CLEOA " MEMREAD " and " MEMWRITE " fonctions, so in that memdump file you investigated for android address's , if i peek in to find something ... how i can calculate proper address for android ?
 

Look for the memory hack software we were using, also check our posts in the Cleo for Android topic.

http://gtaforums.com...android/page-19

 

thanks for your help dude !!! 

 

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

 

:colgate:


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#48

Posted 02 October 2014 - 12:13 PM

Thanks for joining the conversation. Unfortunately I'll be working pretty much 14/7 for the next six weeks so I don't have a lot of time to help, or proof read my PMs (yikes). Can you put the indents back into the pseudocode? If not, please change the color.

 

We could use a better definition for a function. I'm working from my memory of a dead language and I'm worried my info is too far out of date. I'm also not at all sure of how function is being used in GTA IV. You wisely decided to omit that long example you provided in PM, but we're missing the IV example of a function.


ric-013
  • ric-013

    Casual Lurker

  • Members
  • Joined: 24 Nov 2006
  • None

#49

Posted 02 October 2014 - 03:26 PM Edited by ric-013, 02 October 2014 - 03:36 PM.

in gta IV scripts opcodes are called " native fonctions "  but that's not what i was talking about ...

 

what i meant:

in C script i can create what i call a " nested fonction "  ... note : i learned C from french tutorials so my terms might just be mixed up

 

here a example :

// Declared local variable - unsigned int's 
uint a = 0; 				
uint b = 0;				

// created fonction hosting unit c setting - not declared above -
void myFonction(uint c)			
{
	a = c; 	// uint a receive value of uint c setting
	b = 1; // unit b is set to 1
}

void callmyfonction(void)
{
	if(b == 0) // conditional, will only run if uint b = 0
	{
		myfonction(1); // call my fonction and give it a value of 1
	}
}

// main always run while the script is active
void main(void)
{	
	while (TRUE)
	{
		WAIT(0);
		callmyfonction();  // in loop 
	}
}

this script pass unit "c" value of 1 to uint "a"  ...

 

so to me , myfonction(uint c); is a nested fonction hosting uint c setting , you pointed in the right direction with the " gosub " its about the same thing . 


ric-013
  • ric-013

    Casual Lurker

  • Members
  • Joined: 24 Nov 2006
  • None

#50

Posted 12 October 2014 - 11:11 AM Edited by ric-013, 04 November 2014 - 06:41 PM.

ok , i tryed to use everything i learned in last few days to contribute to this topic ... so i hunted down a few 1.03 memory address and made some test cleo scripts...
 
located 1.03 memory address ...
 

( Android 1.03 ) block 10 - Zones :


0x00949474    // start of ZonePop SAN_AND
Record size: 0x11 (17 bytes)
Max records: 379 

ZonePop Structure:
  0x00  byte        Gang 0 Density 
  0x01  byte        Gang 1 Density 
  0x02  byte        Gang 2 Density 
  0x03  byte        Gang 3 Density 
  0x04  byte        Gang 4 Density 
  0x05  byte        Gang 5 Density 
  0x06  byte        Gang 6 Density 
  0x07  byte        Gang 7 Density 
  0x08  byte        Gang 8 Density 
  0x09  byte        Gang 9 Density 
  0x0A  byte        Dealer Density 
  0x0B  byte[4]     RBGA color of zone on map/radar
  0x0F  byte        Popcycle Group 
  0x10  byte        Ped-related 
  0x11  (end)


0x0094AE20    // start of ZoneInfo index
Record size: 0x20 (32 bytes)
Max records: 379 

ZoneInfo Structure:
  0x00  char[8]     zone name 
  0x08  char[8]     zone gxt key (for name displayed on-screen)
  0x10  word[3]     x1,y1,z1 (rounded to ints)
  0x16  word[3]     x2,y2,z2 (rounded to ints)
  0x1C  word        id
  0x1E  byte        type
  0x1F  byte        island
  0x20  (end)

( Android 1.03 ) block 23 - Gang Wars :

float   0x0069D970    // current territories under control %
dword   0x0069D974    // biggest gang territories total
dword   0x0069D978    // 2nd biggest gang territories total
dword   0x0069D97c    // 3rd biggest gang territories total
dword   0x0069D98C    // hood atk marker handle
dword   0x0069D990    // hood atk time out
float   0x0069D994    // X center of zone
float   0x0069D998    // Y center of zone
float   0x0069D99C    // Z center of zone
dword   0x0069D9A0    // next hood atk timer
dword   0x0069D9A4    // hood atk stage
dword   0x0069D9A8    // gang id #2
dword   0x0069D9B0    // gang strenght
float   0x0069D9B4    // X player at 3rd kill
float   0x0069D9B8    // Y player at 3rd kill
float   0x0069D9BC    // Z player at 3rd kill
dword   0x0069D9C0    // 3rd kill timer
dword   0x0069D9C8    // current war stage
float   0x0069D9E8    // previous territories under control %
dword   0x0069D9F0    // gang id #1
dword   0x0069D9F4    // index #2
dword   0x0069D9F8    // index #1
byte    0x0069D9FC    // GLN1 war flag ( doberman )
byte    0x0069D9FD    // gang war toggle

Test Scripts:

The CLEO scripts below are TESTING ones , they were made as proof of concept for the above memory locations mapping . 
 
- Add City's Turfs :
this test script use found gang densities , it will randomly give territories in major cities to Ballas / Vagos for a total of 250 .

 

Add City's Turfs - CLEO test script :

Spoiler

Add City's Turfs - Screenshots:

Spoiler

 
- Hood Under Attack Control :
this test script let you trigger or cancel a " hood under attack " situation by pressing 4 ( top center screen ) and 7  ( top right screen ) note: if you cancel the attack you will lose influence.

 

Hood Under Attack Control - CLEO test script :

Spoiler

note : no screenshots ! since it only trigger/cancel hood attacks .
 
 
- Random Gang Hood Attacks :
this test script set a random gang in" hoods under attack " situations. expect all gangs of SA to attack your territories ( ballas, gsf ,vagos , rifa, danang, mafia, triads, aztecas ) even GSF will attack its own turfs ! kinda funny , imagine a mutiny of rogue gang members and remember this is a TEST script. note: if you fail to defend you territory you will lose influence and rival gang who win  will get density in territory .

 

Random Gang Hood Attacks - CLEO test script :

Spoiler

Random Gang Hood Attacks - Screenshots :

Spoiler

 
 
so this is what i got for now ... i will continue my script learning and 1.03 memory mapping ( ill continue block 23 and popcycle mapping ).
 
i got a question , thoses memory address are 1.05 specific ! how can we make it work on all version ? i seen the all version radar script that call for a label then get top of stucture memory address from that label ... tbh i didnt quite understand how it works.

 

EDIT #2: updated with new info's .... again !

EDIT #3 : noob mistake ... i was on 1.03 not 1.05 ( changed version listing )

  • OrionSR and khsh97 like this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#51

Posted 12 October 2014 - 05:46 PM

Great work, ric. Thanks for all the mobile gang war info; I've been meaning to track that down.

 

Please don't worry about being off topic. The primary purpose of this topic is to move PM conversations regarding getting started with hex editing, save modifications, IPL editing, custom data files, and getting started with Cleo scripting out into the open where I can reference it later, track it down with search engines and generally make the information available to lurkers that like to work from examples.

 

A possible strategy for confirming XYZ data in the gang war block is to seed unique floats into the save file where all the fields should be fairly well documented, then load the save and search for the decimal equivalent with the mem-hacker without triggering any gang war activity that might overwrite your data (load indoors and stay there).

 

Um... I'm not entirely sure if it makes a difference or not, but we should check if there are any limitations on the length of thread names. Frequently we are limited to 7 characters and a null terminator on certain strings, but don't know if it applies in this situation. This may not hold true for all of my examples, but I've been adopting the strategy of commenting out the thread name for scripts that run straight through and end on their own.


ric-013
  • ric-013

    Casual Lurker

  • Members
  • Joined: 24 Nov 2006
  • None

#52

Posted 13 October 2014 - 03:15 PM Edited by ric-013, 04 November 2014 - 06:44 PM.

note : i moved part of my last post into this one , so all related info's are in a single place.

 

based on my old ps2 documentations and memory dump posted in this forum , i located where popcycles models are in memory.

 

starting point of each popcycle data ( cars / peds )

( Android 1.03 ) CARS POPCYCLE models

0x009B1FF0      // start of CARS POPCYCLE models
Structure is populated by cargrp.dat at game start
Record Size : 0x2E (46 bytes)
Max Records : 33
All fields are words, model ID
note : any unused id fields ( WORD ) should be 0x07D0

Index of Records :
0     WORKERS
1     BUISNESS
2     CLUBBERS
3     FARMERS
4     BEACHFOLKS
5     PARKFOLKS
6     CASUAL_RICH
7     CASUAL_AVERAGE
8     CASUAL_POOR
9     PROSTITUTES
10    CRIMINALS
11    GOLFERS
12    SERVANTS
13    AIRCREW
14    ENTERTAINERS
15    OUTOFTOWNFACTORY
16    DESERTFOLKS
17    AIRCREWRUNWAY
18    GANG0
19    GANG1
20    GANG2
21    GANG3
22    GANG4
23    GANG5
24    GANG6
25    GANG7
26    GANG8
27    GANG9
28    DEALERS
29    BOATS
30    CHEAT1(sh*tCARS)
31    CHEAT2(FASTCARS)
32    CHEAT3(NINJA)
33    CHEAT4(FUNHOUSE) 
( Android 1.03 ) PEDS POPCYCLE models

0x009B260C       // start of PEDS POPCYCLE models
Record Size : 0x2A (42 bytes)
Max Records : 56
All fields are words, model ID
note : any unused id fields ( WORD ) should be 0x07D0

Index of records:
0    WORKERS(LS)
1    WORKERS(SF)
2    WORKERS(LV)
3    BUISNESS(LS)
4    BUISNESS(SF)
5    BUISNESS(LV)
6    CLUBBERS(LS)
7    CLUBBERS(SF)
8    CLUBBERS(LV)
9    FARMERS
10   BEACHFOLKS
11   PARKFOLKS(LS)
12   PARKFOLKS(SF)
13   PARKFOLKS(LV)
14   CASUALRICH(LS)
15   CASUALRICH(SF)
16   CASUALRICH(LV)
17   CASUALAVERAGE(LS)
18   CASUALAVERAGE(SF)
19   CASUALAVERAGE(LV)
20   CASUALPOOR(LS)
21   CASUALPOOR(SF)
22   CASUALPOOR(LV)
23   PROSTITUTES(LS)
24   PROSTITUTES(SF)
25   PROSTITUTES(LV)
26   CRIMINALS(LS)
27   CRIMINALS(SF)
28   CRIMINALS(LV)
29   GOLFERS
30   SERVANTS(LS)
31   SERVANTS(SF)
32   SERVANTS(LV)
33   AIRCREW(LS)
34   AIRCREW(SF)
35   AIRCREW(LV)
36   ENTERTAINERS(LS)
37   ENTERTAINERS(SF)
38   ENTERTAINERS(LV)
39   OUTOFTOWNFACTORY
40   DESERTFOLKS
41   AIRCREWRUNWAY
42   GANG0
43   GANG1
44   GANG2
45   GANG3
46   GANG4
47   GANG5
48   GANG6
49   GANG7
50   GANG8
51   GANG9
52   DEALERS
53   SHOPKEEPERS
54   OFFICEWORKERS
55   HUSBANDS
56   WIVES

List of starting address sorted by POPCYCLE types :

Spoiler

 

test script :

The CLEO script below is for TESTING , it was made as proof of concept for the above memory locations mapping .

 

- Groove Gang Are Strippers And Drive NRG500 :
this test script will change your gang for strippers and they will drive NRG-500
note: not savable.

 

Groove Gang Are Strippers And Drive NRG500 - CLEO test script :

Spoiler

Groove Gang Are Strippers And Drive NRG500 - screenshots :

Spoiler

 

ill now resume my block 23 search to locate XYZ's and " out of zone " timer ... thanks for tip on seeding savefile .

 

i did not notice any issue toward " thread name " lenght .

 

EDIT : made some corrections .

EDIT #2 : updated to OrionSR format and added spoilers.

EDIT #3 noob mistake , i was on 1.03 not 1.05 ( changed version id )

  • khsh97 likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#53

Posted 14 October 2014 - 09:33 AM

I'm not sure that you would notice a problem with long thread names unless you were checking if the thread was active or ending it remotely. The documentation suggests that long thread names will get truncated to 8 characters (probably 7 + null) in memory so End Thread 'LongNameA' might kill thread 'LongNameB'.

 

 

Target Marker Index

 

The target/map marker variables are usually described as a dword that indicates the index of the marker. This only explains half the story. The lower word of the dword is the index that can be used to calculate the location of a marker record in the marker pool. The upper word is being used to indicate if the marker is active, but I'm not entirely sure what this information is.

 

Example: 57 00 02 00

 

The marker index is 0x57 and since this was the first marker on a new save the upper word is 0x02. The upper word will increment each time a new marker is placed as the game is running, but is 0 when the marker is absent. I'm not sure how this information changes or is used differently over time.

 

This extra info in the upper word appears to be consistent with how radar marker and pickup indexes are stored in global variables. This appears to be how the game can distinguish an active marker or pickup at index 0. I suspect the extra info is used by opcode that determine if these items exist.

 

I still need to confirm these conclusions but I think I have all the information I need to completely remove a map marker. The idea is to have a version of the teleport to marker script that teleports whenever the marker is set and then fully removes the marker so it's ready to be set again. This information should also make it easier to check if the target marker is set without verifying the icon in the marker pool.


ric-013
  • ric-013

    Casual Lurker

  • Members
  • Joined: 24 Nov 2006
  • None

#54

Posted 14 October 2014 - 05:29 PM Edited by ric-013, 14 October 2014 - 05:30 PM.

i understand the " name thread " lenght issue now ! thanks .

 

that said ... i dont think ill do any multi script thing , i seen the " start new thread with args " opcode and assumed it was possible , but i wont be doing any large mods anytime soon .


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#55

Posted 15 October 2014 - 10:11 PM

Length of thread names - 7 alphanumeric characters: As an "introductory" topic we should set the proper example and follow known conventions. I'd certainly welcome any evidence that contradicts or confirms my current understanding on this issue.
 
 
Memory Mapping:
 
I'm not entirely sure how "pool" is defined in the context of SA memory. I tend to use the term as similar to a Block in a save file. The main difference to me is that a pool is in memory and a block is in the save. In practice however, memory pools tend to be much more discrete than save blocks. For example, the garage block has meta info on all the garages, a series of records (structure) controlling the garage coordinates, and another structure recording the contents of the save garages. Based on what I've seen so far, I would predict that each of these structures would be an independent memory pool.
 
The goal is to provide a programmer with all of the information required to read from or write to any specific field in a structure given the starting address of the structure as the only frame of reference. For now we will start with a hard coded 1.05 address. Provided more information we could run a version check and set starting address for known versions early in a script. Eventually we will want to call for the starting address using CleoA opcodes and magic hex string to maintain compatibility with any version.
 
Structures are usually a series of records, although sometimes, like for gang wars, there is only one record. Records contain fields of a specific size and data type. To operate with a field the programmer needs to know:
 
Data type: model ID, coordinate, max armor, flags, etc. Sometimes a lot of clarification or reference is needed.
Field Size: Byte, word, dword, float (4 bytes), number of character, etc.
Field offset in bytes from the beginning of the record.
Record index: number of records to skip from the beginning of the structure (1st record is index 0)
Record length: number of bytes in a record. (index * record length = offset from beginning of structure)
Address for start of structure
 
We don't have many ideal examples to work with, so lets start with indexing the car groups. The field offsets aren't really an issue here since everything is the same size and type.

0x009B1FF0 // Android 1.05 start of CARS POPCYCLE models
Record Length 0x2E (46 bytes)
All fields are words, model ID
Max fields is 23
Structure is populated by cargrp.dat at game start
note : any unused id fields ( WORD ) should be 0x07D0

Index of Records
0    WORKERS
1    BUISNESS
2    CLUBBERS
3    FARMERS
4    BEACHFOLKS
5    PARKFOLKS
6    CASUAL_RICH
7    CASUAL_AVERAGE
8    CASUAL_POOR
9    PROSTITUTES
10    CRIMINALS
11    GOLFERS
12    SERVANTS
13    AIRCREW
14    ENTERTAINERS
15    OUTOFTOWNFACTORY
16    DESERTFOLKS
17    AIRCREWRUNWAY
18    GANG0
19    GANG1
20    GANG2
21    GANG3
22    GANG4
23    GANG5
24    GANG6
25    GANG7
26    GANG8
27    GANG9
28    DEALERS
29    BOATS
30    CHEAT1(sh*tCARS)
31    CHEAT2(FASTCARS)
32    CHEAT3(NINJA)
33    CHEAT4(FUNHOUSE)

My spreadsheet turned up some possible errors in your hard coded addresses. Please check Parkfolk 9B20d6, Aircrew 9B2246, and AircrewRunway 9B22Fe. Also, the casual distinctions were omitted.
 
I was thinking about working up field offsets for the gang war block, but it's really difficult to identify anything that might be a start of structure. Based on the save info, I'd expect at least some gang war related data before your first identified field of hood atk marker handle. So may as well stick with the hard coded addresses pending more complete information. In the mean time the field descriptions should at least get a field size update, and perhaps a little more info on the data type.
 
 So here's a little better example of what I'm working towards. This was borrowed from PC memory documentation but I'm pretty sure everything hold true for mobile as well.

0x6BF80C  (Android 1.05)  // points to enex pointer (add_ib 1) 
enex pointer holds add_ib 0 address of start of enex records
enex pointer is at an add_ib 0 address
enex destinations use add_ib 0 addresses

Record size: 0x3C (60 bytes)
Max records: 400 (376 standard)

Most data populated from IPL files at game start
Flag and relative links are loaded from save
See enex doc below for index, flag, and data types
http://gtaforums.com/topic/331835-san-andreas-enex-documentation/

0x00 character[7]        Name of Enex string
0x07 byte                nul terminator of string (00)
0x08 float               XinMin (X - X width/2)
0x0C float               YinMax (Y + Y width/2)
0x10 float               XinMax (X + X width/2)
0x14 float               YinMin (Y - Y width/2)
0x18 float               Z in Coord + 1.0
0x1C byte[4]             (unknown) possibly related to unknown Rot1??  - cannot decode
0x20 float               X out Coord
0x24 float               Y out Coord
0x28 float               Z out Coord + 1.0
0x2C float               Out Angle
0x30 word                door flags
0x32 byte                Interior number
0x33 byte                Sky
0x34 byte                Time On
0x35 byte                Time Off
0x36 byte                I2 (unknown)
0x37 byte                (unknown)
0x38 dword               destination address

ric-013
  • ric-013

    Casual Lurker

  • Members
  • Joined: 24 Nov 2006
  • None

#56

Posted 16 October 2014 - 04:08 PM Edited by ric-013, 18 October 2014 - 05:23 PM.

i edited my previous post with address corrections ... thanks for pointing out the errors.

 

i do further edits this weekend ... script names lenght corrections and ill use format you suggested above ( thanks for the car popcycle example ) 

 

from my peeks in memory , block 23 seems to start at 0x0069D95C ( there a bunch of nop lines above it ) 

 

also i located block 23 XYZ's floats ...

note : moved to my post on gang-war memory location above.

however i lacked time to proof test them yet ... again ill do so this weekend.

EDIT: tested ! 


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#57

Posted 19 October 2014 - 04:20 AM

Outstanding job on your updates. That's exactly what I was hoping for.

  • ric-013 likes this

ric-013
  • ric-013

    Casual Lurker

  • Members
  • Joined: 24 Nov 2006
  • None

#58

Posted 19 October 2014 - 07:58 PM Edited by ric-013, 04 November 2014 - 06:46 PM.

thanks dude ... your example helped alot  ! i continued my memory peeks ...

 

- updated mapping of block 23 again ( see a few posts above )

- edited / upgraded Popcycle mapping to your suggested format ( see a few post above )

- found and tested block 11 - Gang Weapons

 

 

here's block 11 memory mapping :

( android 1.03 ) Block 11 - Gang Weapons

0x009AAD10   // start of Gang Weapons 

Record size : 0x10 ( 16 bytes )
max records : 10

Gang Weapons structure :            
  0x00  byte[4]         unused
  0x04  dword           weapon a
  0x08  dword           weapon b
  0x0C  dword           weapon c
  0x10  (end)

Index of records :
0   Ballas
1   Gsf
2   Vagos
3   Rifa
4   Danang
5   Mafia
6   Triads
7   Aztecas
8   Unused gang
9   Unused gang

Test Script :

The CLEO script below is for TESTING , it was made as proof of concept for the above memory locations mapping .

 

- All Gangs Have Miniguns

This test script will set miniguns to all gangs .( not in war waves , some streets wandering gang members carry them )

 

All Gangs Have Miniguns - CLEO test script :

Spoiler

All Gangs Have Miniguns - Screenshots :

Spoiler

 

EDIT : i was on 1.03 not 1.05 ( changed version id )

  • OrionSR likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#59

Posted 03 November 2014 - 11:08 PM Edited by OrionSR, 03 November 2014 - 11:25 PM.

SA Mobile 1.06 for Android - Changes to Save Structure

 

File ID: C3 28 77 14 - 0x147728C3

File Size: 195,000 bytes

 

GTASnP can now accept v1.06 save files.

v1.05 saves are compatible with the 1.06 game but not the other way around.

 

The major change is the omission of the annoying c0de (DE C0) words that seemed to proceed each write operation. The 1.06 saves are slightly compatible with SASE. Some tabs seem to display correct information but I have no idea if editing is possible. SASE has some problems anyway so I'm anticipating some nasty glitches.

 

Misc - useless

Script - global variables appear to displayed correctly (switch between int, hex, float display). The rest is broken.

Player - some info might be correct. Health, armor and fat look broken.

Object - broken, no surprise since the record format is different.

Garage - locations look correct, no other data on a superclean save.

Pickup - looks good

Zone - looks better than usual

Gang Weapon - looks good

Car Generator - looks good

Stats - looks good

Ped Acquaintance - looks good

Tag - looks good

Unique Stunt - looks good

 

I have been unable to get SAMA or the Savegame Editor v3.x to work on 1.06 saves without cutting and pasting mobile blocks into a PC save. However, this process is now a lot easier without the c0de words cluttering up the records.

 

 

PCv1 and 1.06 Block Size Comparison

(superclean beginning saves, cleo is used to save ASAP)

 

All blocks appear to have the same structure except:

 

Misc (+116 bytes): +100 characters for the unicode save name and +16 bytes unknown.

Main (+6720 bytes) Includes additional global variables, new mission skip thread, and additional locals for each thread

Players & Objects (+332 bytes) Mobile object records are larger, player structure may be altered

Markers (+3000 bytes) 75 additional 40 byte records. 250 max records (PC, 1.05=175).

 

So apparently the 1.06 save files are smaller than PC save files because they are using less slack, the garbage data at the end of file that keeps the file size the same despite changing block sizes. It's a good thing the extra object glitch appears to be fixed. Some of those glitchy saves were close to running out of slack completely.

 

 

Update: Interesting. It appears that the 1.05 saves only included 175 marker records. I wonder if the additional 75 marker records is a response to crappy cleo mods cluttering up the radar pool. If so it's a pretty poor strategy. It won't help for long if the offending scripts aren't removed.


kevinwilliszjs
  • kevinwilliszjs

    Player Hater

  • Members
  • Joined: 20 May 2014
  • China

#60

Posted 04 November 2014 - 08:42 AM

i found in 1.06 obb file it has playerhi texture file,and find libGTASA.so has this tag,but i don’t know how to use this?

 

 i also find the magic hex code  “gMobileMenu” and “_ZN6CRadar13ms_RadarTraceE” in libGTASA.so file,and also don't how it works?

 

and this is my modified 1.06apkwithcleo not need obb file to run

download link http://pan.baidu.com/s/1gdnEGj5





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users