Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;###########################
- ; Credits: Beach LTS Developer
- ; NextGenUpdate
- ; http://www.nextgenupdate.com/forums/gta-5-scripts-codes/866651-c-powerpc-machine-code-teleport-gun-script-1-26-a.html#post6777176
- ; "[C++][POWERPC][MACHINE CODE] TELEPORT GUN SCRIPT [1.26]"
- ;###########################
- ;Game Hooking
- ;To execute our own function, we need to hijack one of the games functions which is constantly called, and make it call our function.
- ;One native which is constantly being called is "IS_PLAYER_ONLINE", which is at the address 0x3E3A20 in 1.26.
- ;We need to find a PPC instruction which is un-needed, or something which can be simply fixed in our own function.
- ;This is the function IS_PLAYER_ONLINE, if we go into the bl, we see a relatively small function which has enough room for us to replace 4 instructions, and is easy to replicate. ;(No hooking issues)
- ;Now if the jump was small enough, we could simply replace the load immediate for a branch link, but the jump in this case is too large, therefore
- ;we need to replace 4 lines,
- lis r4, byte_2242320@h
- li r3, 0
- lbz r4, byte_2242320@l(r4)
- cmpwi r4, 0
- ;but because we don't want to break this native, we will NOP the remaining instructions in this function (except blr).
- beq 12D8E84
- li r3, 1
- ;And we will replace these four lines with;
- lis %r11, 0x1D0
- ori %r11, %r11, 0x0030
- mtctr %r11
- bctrl
- NOP
- NOP
- ;Which will store 0x1D00030 into r11, then set the program counter to that value. (Essentially jumping)
- ;IMG HERE: http://i.imgur.com/a28MmT7.png
- ;Hook In Memory
- ;IMG HERE: http://i.imgur.com/PlI2wxN.png
- ;C++
- ;bool IsOn = false;
- ;Vector3 Coords;
- ;void main()
- ;{
- ;
- ;while(true)
- ;{
- ;
- ;if (IS_CONTROL_PRESSED(0, 0xCC)) //DPAD_LEFT
- ;{
- ;
- ;IsOn = !IsOn; //Invert Boolean Toggle
- ;if (IsOn)
- ;{
- ;
- ;UI::_0xF42C43C7("STRING");
- ;UI::_ADD_TEXT_COMPONENT_STRING("~g~On"); //Display Notification
- ;UI::_0x38F82261(4000, false);
- ;}
- ;else
- ;{
- ;
- ;UI::_0xF42C43C7("STRING");
- ;UI::_ADD_TEXT_COMPONENT_STRING("~r~Off"); //Display Notification
- ;UI::_0x38F82261(4000, false);
- ;}
- ;}
- ;if (IsOn) //If its enabled
- ;{
- ;
- ;if (GET_PED_LAST_WEAPON_IMPACT_COORD(PLAYER_PED_ID(), &Coords)) //If you have recently just shot
- ;{
- ;
- ;SET_ENTITY_COORDS(PLAYER_PED_ID(), Coords.x, Coords.y, Coords.z, true, false, false, true); //Set your player to the impact coord location.
- ;}
- ;}
- ;}
- ;}
- ;Assembly (Power PC)
- stdu %r1, -0x70(%r1)
- mflr %r0
- std %r0, 0x80(%r1)
- li %r3, 0 ;Local Client
- li %r4, 0xCC ;DPAD_LEFT Index
- bl 0x400414 ;IS_CONTROL_PRESSED
- cmpwi %r3, 0 ;Compare with 0
- beq :EndIfControlPressed ;Jump to end of If, if previous compare was equal.
- li %r3, :IsOn_Lower ;Load IsOn address lower
- addic %r3, %r3, :IsOn_Higher ;Load IsOn address upper
- lbz %r3, 0(%r3) ;Read :IsOn and store in r3
- cmpwi %r3, 0 ;Compare with 0
- beq :IsOnFalse[ELSE] ;Jump to else if equal
- li %r3, :IsOn_Lower ;Load IsOn address lower
- addic %r3, %r3, :IsOn_Higher ;Load IsOn address upper
- li %r4, 0 ;IsOn = false
- stb %r4, 0(%r3) ;Write to memory
- b :IsOnFalse[END]
- :IsOnFalse[ELSE]
- li %r3, :IsOn_Lower ;Load IsOn address lower
- addic %r3, %r3, :IsOn_Higher ;Load IsOn address upper
- li %r4, 1 ;IsOn = true
- stb %r4, 0(%r3) ;Write to memory
- :IsOnFalse[END]
- li %r3, :IsOn_Lower ;Load IsOn address lower
- addic %r3, %r3, :IsOn_Higher ;Load IsOn address upper
- lbz %r3, 0(%r3) ;Read :IsOn and store in r3
- cmpwi %r3, 0 ;Compare with 0
- beq :IsOnTrue[ELSE] ;Jump to else if equal
- li %r3, :stringTxt_Lower ;Load stringTxt address lower
- addic %r3, %r3, :stringTxt_Higher ;Load stringTxt address upper
- bl 0x3C8210 ; UI::_0xF42C43C7
- li %r3, :stringOn_Lower ;Load stringOn address lower
- addic %r3, %r3, :stringOn_Higher ;Load stringOn address upper
- bl 0x3C85D0 ; UI::_ADD_TEXT_COMPONENT_STRING [0x27A244D8]
- li %r3, 4000 ;Time Ms
- li %r4, 0
- bl 0x3C8230 ;UI::_0x38F82261
- b :IsOnTrue[END]
- :IsOnTrue[ELSE]
- li %r3, :stringTxt_Lower ;Load stringTxt address lower
- addic %r3, %r3, :stringTxt_Higher ;Load stringTxt address upper
- bl 0x3C8210 ; UI::_0xF42C43C7
- li %r3, :stringOff_Lower ;Load stringOff address lower
- addic %r3, %r3, :stringOff_Higher ;Load stringOff address upper
- bl 0x3C85D0 ; UI::_ADD_TEXT_COMPONENT_STRING [0x27A244D8]
- li %r3, 4000 ;Time Ms
- li %r4, 0
- bl 0x3C8230 ;UI::_0x38F82261
- :IsOnTrue[END]
- :EndIfControlPressed ;End of IS_CONTROL_PRESSED if statement.
- li %r3, :IsOn_Lower ;Load IsOn address lower
- addic %r3, %r3, :IsOn_Higher ;Load IsOn address upper
- lbz %r3, 0(%r3) ;Read :IsOn and store in r3
- cmpwi %r3, 0 ;Compare with 0
- beq :IsOnTrueConstant[END] ;Jump to end if equal
- bl 0x424218 ;PLAYER_PED_ID
- li %r3, :Coords_Lower ;Load Coords address lower
- addic %r3, %r3, :Coords_Higher ;Load Coords address upper
- li %r4, :Coords_Lower ;Load Coords address lower
- addic %r4, %r4, :Coords_Higher + 4 ;Load Coords address upper
- li %r5, :Coords_Lower ;Load Coords address lower
- addic %r5, %r5, :Coords_Higher + 8 ;Load Coords address upper
- bl 0x468F40 ;GET_PED_LAST_WEAPON_IMPACT_COORD
- cmpwi %r3, 0 ;Compare with 0
- beq :HasShot[END] ;Jump to end if equal
- bl 0x424218 ;PLAYER_PED_ID
- li %r4, :Coords_Lower ;Load Coords address lower
- addic %r4, %r4, :Coords_Higher ;Load Coords address upper
- lfs %f1, 0(%r4)
- lfs %f2, 4(%r4)
- lfs %f3, 8(%r4)
- li %r5, 1
- li %r6, 0
- li %r7, 0
- li %r8, 1
- bl 0x3B3160 ;SET_ENTITY_COORDS
- :HasShot[END]
- :IsOnTrueConstant[END]
- ld %r0, 0x80(%r1)
- mtlr %r0
- addi %r1, %r1, 0x70
- blr
- ;Memory Data
- :IsOn
- :Coords
- :stringTxt = "STRING"
- :stringOff = "~r~Off"
- :stringOn = "~g~On"
- ;Machine Code (Currently Compiling and testing)
- ;Write Hook to IS_PLAYER_ONLINE
- ;Write hook 0x1D00030 to 0x12D8E6C
- ;Variable Data
- 0x1D00000 = :IsOn
- 0x1D00004 = :Coords
- 0x1D00010 = :stringTxt
- 0x1D00018 = :stringOff
- 0x1D00020 = :stringOn
- ;Calculated Jumps, removed comments and other non-needed data.
- stdu %r1, -0x70(%r1)
- mflr %r0
- std %r0, 0x80(%r1)
- li %r3, 0
- li %r4, 0xCC
- bl 0x400414
- cmpwi %r3, 0
- beq 0x9C
- li %r3, 0
- addic %r3, %r3, 0x1D0
- lbz %r3, 0(%r3)
- cmpwi %r3, 0
- beq 0x18
- li %r3, 0
- addic %r3, %r3, 0x1D0
- li %r4, 0
- stb %r4, 0(%r3)
- b 0x14
- li %r3, 0
- addic %r3, %r3, 0x1D0
- li %r4, 1
- stb %r4, 0(%r3)
- li %r3, 0
- addic %r3, %r3, 0x1D0
- lbz %r3, 0(%r3)
- cmpwi %r3, 0
- beq 0x2C
- li %r3, 0x10
- addic %r3, %r3, 0x1D0
- bl 0x3C8210
- li %r3, 0x20
- addic %r3, %r3, 0x1D0
- bl 0x3C85D0
- li %r3, 4000
- li %r4, 0
- bl 0x3C8230
- b 0x28
- li %r3, 0x10
- addic %r3, %r3, 0x1D0
- bl 0x3C8210
- li %r3, 0x18
- addic %r3, %r3, 0x1D0
- bl 0x3C85D0
- li %r3, 4000
- li %r4, 0
- bl 0x3C8230
- li %r3, 0
- addic %r3, %r3, 0x1D0
- lbz %r3, 0(%r3)
- cmpwi %r3, 0
- beq 0x58
- bl 0x424218
- li %r3, 0x04
- addic %r3, %r3, 0x1D0
- li %r4, 0x08
- addic %r4, %r4, 0x1D0
- li %r5, 0x0C
- addic %r5, %r5, 0x1D0
- bl 0x468F40
- cmpwi %r3, 0
- beq 0x30
- bl 0x424218
- li %r4, 4
- addic %r4, %r4, 0x1D0
- lfs %f1, 0(%r4)
- lfs %f2, 4(%r4)
- lfs %f3, 8(%r4)
- li %r5, 1
- li %r6, 0
- li %r7, 0
- li %r8, 1
- bl 0x3B3160
- ld %r0, 0x80(%r1)
- mtlr %r0
- addi %r1, %r1, 0x70
- blr
- ;Machine Code Write To > 0x1D00030
- F8 21 FF 91 7C 08 02 A6 F8 01 00 80 38 60 00 00 38 80 00 CC 4B 71 03 D1 2C 03 00 00 41 82 00 9C 38 60 00 00 30 63 01 CF 88 63 00 00 2C 03 00 00 41 82 00 18 38 60 00 00 30 63 01 CF 38 80 00 00 98 83 00 00 48 00 00 14 38 60 00 00 30 63 01 CF 38 80 00 01 98 83 00 00 38 60 00 00 30 63 01 CF 88 63 00 00 2C 03 00 00 41 82 00 2C 38 60 00 10 30 63 01 CF 4B 6D 81 6D 38 60 00 20 30 63 01 CF 4B 6D 85 21 38 60 0F A0 38 80 00 00 4B 6D 81 75 48 00 00 28 38 60 00 10 30 63 01 CF 4B 6D 81 45 38 60 00 18 30 63 01 CF 4B 6D 84 F9 38 60 0F A0 38 80 00 00 4B 6D 81 4D 38 60 00 00 30 63 01 CF 88 63 00 00 2C 03 00 00 41 82 00 58 4B 73 41 1D 38 60 00 04 30 63 01 CF 38 80 00 08 30 84 01 CF 38 A0 00 0C 30 A5 01 CF 4B 77 8E 29 2C 03 00 00 41 82 00 30 4B 73 40 F5 38 80 00 04 30 84 01 CF C0 24 00 00 C0 44 00 04 C0 64 00 08 38 A0 00 01 38 C0 00 00 38 E0 00 00 39 00 00 01 4B 6C 30 15 E8 01 00 80 7C 08 03 A6 38 21 00 70 4E 80 00 20
- ;Last edited by Beach; 11-20-2015 at 10:44 AM.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement