Announcement

Collapse
No announcement yet.

SOCOM II Live Character Model Swap

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SOCOM II Live Character Model Swap

    Swapper v1.3 [L1+Left]
    D044F15C 0000FB7F
    202CED04 08027C00
    2009F000 27BDFFC0
    2009F004 FFBF0040
    2009F008 7FB30030
    2009F00C 7FB20020
    2009F010 7FB10010
    2009F014 7FB00000
    2009F018 3C100044
    2009F01C 36100C38
    2009F020 8E100000
    2009F024 1200002B
    2009F028 00000000
    2009F02C 3C110009
    2009F030 3631EF70
    2009F034 8232000A
    2009F038 12400018
    2009F03C 00000000
    2009F040 24190039
    2009F044 12590020
    2009F048 00000000
    2009F04C 3C0E000A
    2009F050 35CE0000
    2009F054 8DD30000
    2009F058 24080020
    2009F05C 12680005
    2009F060 00000000
    2009F064 26730001
    2009F068 ADD30000
    2009F06C 10000019
    2009F070 00000000
    2009F074 0C14F85C
    2009F078 0220202D
    2009F07C AE020540
    2009F080 3C0C6666
    2009F084 358C6666
    2009F088 AE0C0FCC
    2009F08C 26520001
    2009F090 A232000A
    2009F094 1000000E
    2009F098 00000000
    2009F09C 3C086843
    2009F0A0 35086955
    2009F0A4 3C097954
    2009F0A8 35297261
    2009F0AC 3C0A0031
    2009F0B0 354A6570
    2009F0B4 AE280000
    2009F0B8 AE290004
    2009F0BC AE2A0008
    2009F0C0 10000004
    2009F0C4 00000000
    2009F0C8 240F0031
    2009F0CC A22F000A
    2009F0D0 ADC00000
    2009F0D4 DFBF0040
    2009F0D8 7BB30030
    2009F0DC 7BB20020
    2009F0E0 7BB10010
    2009F0E4 7BB00000
    2009F0E8 03E00008
    2009F0EC 27BD0040



    D044F15C 0000FFFF
    202CED04 03e00008

    Respawn in place
    20599110 00000000

    address $2009f000


    Code:
    addiu sp, sp, $ffc0  //remove 40bytes from stack
    
    sd ra, $0040(sp) //save return address onto stack on offset $0040
    
    sq s3, $0030(sp) //save s3 onto stack at offset $0030
    
    sq s2, $0020(sp) //save s2 onto stack at offset $0020
    
    sq s1, $0010(sp) //save s1 onto stack at offset $0010
    
    sq s0, $0000(sp) //save s0 onto stack at offset $0000
    
    setreg s0, $00440c38 //load our player pointer address into s0
    
    lw s0, $0000(s0) //load our player pointer address. 0=not in game, when in game it will point to our czsealobject
    
    beq s0, zero, :end //if we arent in game (=0) then exit the routine
    
    nop //first line after branch/jump gets loaded. we have nothing left to do if s0=0, so we just leave this as nop (do nothing)
    
    setreg s1, $0009ef70 //we will be storing our string for our character here. ("UiCharType1") The way this works is that in SOCOM 2, you have Type 1-Type 8 ("UiCharType1-8")
    
    lb s2, $000a(s1) //this loads the index of our model. so at offset $000a will be the byte "31-39" (00>31<6570)
    
    beq s2, zero, :print //first time through, this byte will equal zero. so when we press the joker the first time, we want to print "UiCharType1"
    
    nop //do nothing
    
    addiu t9, zero, $0039 //load $00000039 into t9 (last model. Chartype8 (0039) (00>39<6570)
    
    beq s2, t9, :reset //if we are on the last model, then reset back to chartype1
    
    nop //do nothing
    
    setreg t1, $000a0000 //this will be our timer. so we are going to set t1 to address 000a0000
    
    lw s3, $0000(t1) //load the data at 000a0000 into s3
    
    addiu t0, zero, $0020 //set register t0 to $00000020
    
    beq s3, t0, :fnc //if the timer (s3) equals 0020 then swap the character.
    
    nop
    
    addiu s3, s3, $0001 //increment s3 by 1. (the data at 000a0000)
    
    sw s3, $0000(t1) //store the incremented value at 000a0000. we want to keep incrementing the data at 000a0000 until it equals t0. (0020)
    
    beq zero, zero, :end //skip to end
    
    nop //do nothing
    
    fnc: //our character swapping function
    
    jal $0053e170 //this function gets our skin pointer.
    
    daddu a0, s1, zero //we want to pass s1 into the argument register. (s1 is the address holding "UiCharTypeX") so pass this into a0 because the function needs to know which model to
    get the pointer for.
    
    sw v0, $0540(s0) //the pointer for the skin is inside of v0, so we will store that pointer (v0) at offset $0540 (chartype inside our player pointer) *remember s0 has our player pointer
    
    setreg t4, $66666666 //load $66666666 into t4
    
    sw t4, $0fcc(s0) //store $66666666 at offset $0fcc in player pointer.(this forces our character to respawn)
    
    addiu s2, s2, $0001 //increment our model index. so next time joker is pressed, it will switch to the next character in order
    
    sb s2, $000a(s1) //stores our incremented model index at offset $000a
    
    beq zero, zero, :timer //character is swapped and everything has been incremented and stored, skip to reset timer and end routine
    
    nop //do nothing
    
    print: //this prints our first "UiCharType1" when joker is pressed for the first time.
    
    setreg t0, $68436955 //loads $68436955 into t0
    
    setreg t1, $79547261 // loads $79547261 into t1
    
    setreg t2, $00316570 //loads $00316570 into t2
    
    sw t0, $0000(s1) //store t0 at 0009ef70
    
    sw t1, $0004(s1) //store t1 at 0009ef74 (offset $0004)
    
    sw t2, $0008(s1) //store t2 at 0009ef78 (Offset $0008)
    
    beq zero, zero, :end //skip to end routine
    
    nop
    
    reset: //when we are at the last character
    
    addiu t7, zero, $0031 //loads $00000031 into t7
    
    sb t7, $000a(s1) //stores byte "31" at offset $000a
    
    timer:
    
    sw zero, $0000(t1) //stores 0 at 000a0000. resets our timer from 20 to 0 to restart the function
    
    end:
    
    ld ra, $0040(sp) //load our return address
    
    lq s3, $0030(sp) //load s3
    
    lq s2, $0020(sp) //load s2
    
    lq s1, $0010(sp) //load s1
    
    lq s0, $0000(sp) //load s0
    
    jr ra //exit routine
    
    addiu sp, sp, $0040 //return the 40 bytes to the stack


    v1.3 Much shorter, less glitchy. Shoutout to renagade for the idea

    credit: bismofunyuns
    Last edited by bismofunyunss; 01-13-2020, 03:57:15 AM.

  • #2
    Cool code only thing I find is you need too add a timer for when the jokers pressed so it doesn't loop so fast

    Comment


    • #3
      Originally posted by RENEGADE View Post
      Cool code only thing I find is you need too add a timer for when the jokers pressed so it doesn't loop so fast
      Yeah that could be what's causing the models to be random, the model index is being incremented too fast. Will look into that, or could switch to another hook that isn't as constant.

      Comment


      • #4
        yea that too but a timer is the easiest way just at the top of the code check too see if a address at 000x is 10 or 100 gotta play around with it if not add 1 till it is then run the code below

        Comment


        • #5
          Just added a timer and fixed a few bugs. Updated with v1.1

          Comment


          • #6
            This code looks like it wasn't handwritten or compiled in code designer. You have a lot of duplication that could easily be cut out to make this code much smaller to conserve space. Technically you could remove like a 5th of this code if not more. You should try and write a execute once function that relies on a joker press. That way this code will just increment through character models one at a time on joker press. You could also hook this up to display the character model name into a string and have a menu like interface.Good work though!
            Code:
             
            address $0044F15C
            
            dsra32 ra, zero, 13
            address $002CED04
            
            j $000f1200
            address $000F1200
            
            addiu sp, sp, $fff0
            sd ra, $0010(sp)
            sq s7, $0000(sp)
            lui t9, $0100
            ori t9, t9, $0000
            lui t8, $000f
            ori t8, t8, $1100
            lw s7, $0000(t8)
            bne s7, t9, $0003
            nop
            beq zero, zero, $0005
            nop
            addiu s7, s7, $0001
            sw s7, $0000(t8)
            beq zero, zero, $fff8
            nop
            sw zero, $0000(t8)
            jal $000c10a0
            nop
            ld ra, $0010(sp)
            lq s7, $0000(sp)
            jr ra
            addiu sp, sp, $0010
            address $000C1000
            
            ldl v1, $6955(v0)
            lq s4, $7261(t2)
            tge at, s1 (00195)
            address $000C1010
            
            ldl v1, $6955(v0)
            lq s4, $7261(t2)
            tge at, s2 (00195)
            address $000C1020
            
            ldl v1, $6955(v0)
            lq s4, $7261(t2)
            tge at, s3 (00195)
            address $000C1030
            
            ldl v1, $6955(v0)
            lq s4, $7261(t2)
            tge at, s4 (00195)
            address $000C1040
            
            ldl v1, $6955(v0)
            lq s4, $7261(t2)
            tge at, s5 (00195)
            address $000C1050
            
            ldl v1, $6955(v0)
            lq s4, $7261(t2)
            tge at, s6 (00195)
            address $000C1060
            
            ldl v1, $6955(v0)
            lq s4, $7261(t2)
            tge at, s7 (00195)
            address $000C1070
            
            ldl v1, $6955(v0)
            lq s4, $7261(t2)
            tge at, t8 (00195)
            address $000C10A0
            
            addiu sp, sp, $ffc0
            sw ra, $0040(sp)
            sw s3, $0030(sp)
            sw s2, $0020(sp)
            sw s1, $0010(sp)
            sw s0, $0000(sp)
            lui s0, $0044
            ori s0, s0, $0c38
            lw s0, $0000(s0)
            beq s0, zero, $0072
            nop
            addiu t0, zero, $0001
            addiu t1, zero, $0002
            addiu t2, zero, $0003
            addiu t3, zero, $0004
            addiu t4, zero, $0005
            addiu t5, zero, $0006
            addiu t6, zero, $0007
            addiu t7, zero, $0008
            lui t8, $6666
            ori t8, t8, $6666
            lui s1, $000c
            ori s1, s1, $1090
            lw s2, $0000(s1)
            lui s3, $000c
            ori s3, s3, $1000
            beq s2, zero, $0003
            nop
            beq zero, zero, $0005
            nop
            addiu s2, s2, $0001
            sw s2, $0000(s1)
            beq zero, zero, $0001
            nop
            lw s2, $0000(s1)
            beq s2, t0, $0011
            nop
            beq s2, t1, $0018
            nop
            beq s2, t2, $001f
            nop
            beq s2, t3, $0026
            nop
            beq s2, t4, $002d
            nop
            beq s2, t5, $0034
            nop
            beq s2, t6, $003b
            nop
            beq s2, t7, $0042
            nop
            beq zero, zero, $0048
            nop
            jal $0053e170
            addiu a0, s3, $0000
            daddu a1, v0, zero
            sw a1, $0540(s0)
            sw t8, $0fcc(s0)
            addiu s2, s2, $0001
            sw s2, $0000(s1)
            beq zero, zero, $003f
            nop
            jal $0053e170
            addiu a0, s3, $0010
            daddu a1, v0, zero
            sw a1, $0540(s0)
            sw t8, $0fcc(s0)
            addiu s2, s2, $0001
            sw s2, $0000(s1)
            beq zero, zero, $0036
            nop
            jal $0053e170
            addiu a0, s3, $0020
            daddu a1, v0, zero
            sw a1, $0540(s0)
            sw t8, $0fcc(s0)
            addiu s2, s2, $0001
            sw s2, $0000(s1)
            beq zero, zero, $002d
            nop
            jal $0053e170
            addiu a0, s3, $0030
            daddu a1, v0, zero
            sw a1, $0540(s0)
            sw t8, $0fcc(s0)
            addiu s2, s2, $0001
            sw s2, $0000(s1)
            beq zero, zero, $0024
            nop
            jal $0053e170
            addiu a0, s3, $0040
            daddu a1, v0, zero
            sw a1, $0540(s0)
            sw t8, $0fcc(s0)
            addiu s2, s2, $0001
            sw s2, $0000(s1)
            beq zero, zero, $001b
            nop
            jal $0053e170
            addiu a0, s3, $0050
            daddu a1, v0, zero
            sw a1, $0540(s0)
            sw t8, $0fcc(s0)
            addiu s2, s2, $0001
            sw s2, $0000(s1)
            beq zero, zero, $0012
            nop
            jal $0053e170
            addiu a0, s3, $0060
            daddu a1, v0, zero
            sw a1, $0540(s0)
            sw t8, $0fcc(s0)
            addiu s2, s2, $0001
            sw s2, $0000(s1)
            beq zero, zero, $0009
            nop
            jal $0053e170
            addiu a0, s3, $0070
            daddu a1, v0, zero
            sw a1, $0540(s0)
            sw t8, $0fcc(s0)
            sw zero, $0000(s1)
            beq zero, zero, $0001
            nop
            lw ra, $0040(sp)
            lw s3, $0030(sp)
            lw s2, $0020(sp)
            lw s1, $0010(sp)
            lw s0, $0000(sp)
            jr ra
            addiu sp, sp, $0040
            address $0044F15C
            
            dsra32 ra, zero, 31
            address $002CED04
            
            jr ra
            address $00599110
            Last edited by Cronotrigga; 08-13-2019, 12:16:08 PM.

            Comment


            • #7
              Originally posted by Cronotrigga View Post
              This code looks like it wasn't handwritten or compiled in code designer. You have a lot of duplication that could easily be cut out to make this code much smaller to conserve space. Technically you could remove like a 5th of this code if not more. You should try and write a execute once function that relies on a joker press. That way this code will just increment through character models one at a time on joker press. You could also hook this up to display the character model name into a string and have a menu like interface.Good work though!
              Code:
              address $0044F15C
              
              dsra32 ra, zero, 13
              address $002CED04
              
              j $000f1200
              address $000F1200
              
              addiu sp, sp, $fff0
              sd ra, $0010(sp)
              sq s7, $0000(sp)
              lui t9, $0100
              ori t9, t9, $0000
              lui t8, $000f
              ori t8, t8, $1100
              lw s7, $0000(t8)
              bne s7, t9, $0003
              nop
              beq zero, zero, $0005
              nop
              addiu s7, s7, $0001
              sw s7, $0000(t8)
              beq zero, zero, $fff8
              nop
              sw zero, $0000(t8)
              jal $000c10a0
              nop
              ld ra, $0010(sp)
              lq s7, $0000(sp)
              jr ra
              addiu sp, sp, $0010
              address $000C1000
              
              ldl v1, $6955(v0)
              lq s4, $7261(t2)
              tge at, s1 (00195)
              address $000C1010
              
              ldl v1, $6955(v0)
              lq s4, $7261(t2)
              tge at, s2 (00195)
              address $000C1020
              
              ldl v1, $6955(v0)
              lq s4, $7261(t2)
              tge at, s3 (00195)
              address $000C1030
              
              ldl v1, $6955(v0)
              lq s4, $7261(t2)
              tge at, s4 (00195)
              address $000C1040
              
              ldl v1, $6955(v0)
              lq s4, $7261(t2)
              tge at, s5 (00195)
              address $000C1050
              
              ldl v1, $6955(v0)
              lq s4, $7261(t2)
              tge at, s6 (00195)
              address $000C1060
              
              ldl v1, $6955(v0)
              lq s4, $7261(t2)
              tge at, s7 (00195)
              address $000C1070
              
              ldl v1, $6955(v0)
              lq s4, $7261(t2)
              tge at, t8 (00195)
              address $000C10A0
              
              addiu sp, sp, $ffc0
              sw ra, $0040(sp)
              sw s3, $0030(sp)
              sw s2, $0020(sp)
              sw s1, $0010(sp)
              sw s0, $0000(sp)
              lui s0, $0044
              ori s0, s0, $0c38
              lw s0, $0000(s0)
              beq s0, zero, $0072
              nop
              addiu t0, zero, $0001
              addiu t1, zero, $0002
              addiu t2, zero, $0003
              addiu t3, zero, $0004
              addiu t4, zero, $0005
              addiu t5, zero, $0006
              addiu t6, zero, $0007
              addiu t7, zero, $0008
              lui t8, $6666
              ori t8, t8, $6666
              lui s1, $000c
              ori s1, s1, $1090
              lw s2, $0000(s1)
              lui s3, $000c
              ori s3, s3, $1000
              beq s2, zero, $0003
              nop
              beq zero, zero, $0005
              nop
              addiu s2, s2, $0001
              sw s2, $0000(s1)
              beq zero, zero, $0001
              nop
              lw s2, $0000(s1)
              beq s2, t0, $0011
              nop
              beq s2, t1, $0018
              nop
              beq s2, t2, $001f
              nop
              beq s2, t3, $0026
              nop
              beq s2, t4, $002d
              nop
              beq s2, t5, $0034
              nop
              beq s2, t6, $003b
              nop
              beq s2, t7, $0042
              nop
              beq zero, zero, $0048
              nop
              jal $0053e170
              addiu a0, s3, $0000
              daddu a1, v0, zero
              sw a1, $0540(s0)
              sw t8, $0fcc(s0)
              addiu s2, s2, $0001
              sw s2, $0000(s1)
              beq zero, zero, $003f
              nop
              jal $0053e170
              addiu a0, s3, $0010
              daddu a1, v0, zero
              sw a1, $0540(s0)
              sw t8, $0fcc(s0)
              addiu s2, s2, $0001
              sw s2, $0000(s1)
              beq zero, zero, $0036
              nop
              jal $0053e170
              addiu a0, s3, $0020
              daddu a1, v0, zero
              sw a1, $0540(s0)
              sw t8, $0fcc(s0)
              addiu s2, s2, $0001
              sw s2, $0000(s1)
              beq zero, zero, $002d
              nop
              jal $0053e170
              addiu a0, s3, $0030
              daddu a1, v0, zero
              sw a1, $0540(s0)
              sw t8, $0fcc(s0)
              addiu s2, s2, $0001
              sw s2, $0000(s1)
              beq zero, zero, $0024
              nop
              jal $0053e170
              addiu a0, s3, $0040
              daddu a1, v0, zero
              sw a1, $0540(s0)
              sw t8, $0fcc(s0)
              addiu s2, s2, $0001
              sw s2, $0000(s1)
              beq zero, zero, $001b
              nop
              jal $0053e170
              addiu a0, s3, $0050
              daddu a1, v0, zero
              sw a1, $0540(s0)
              sw t8, $0fcc(s0)
              addiu s2, s2, $0001
              sw s2, $0000(s1)
              beq zero, zero, $0012
              nop
              jal $0053e170
              addiu a0, s3, $0060
              daddu a1, v0, zero
              sw a1, $0540(s0)
              sw t8, $0fcc(s0)
              addiu s2, s2, $0001
              sw s2, $0000(s1)
              beq zero, zero, $0009
              nop
              jal $0053e170
              addiu a0, s3, $0070
              daddu a1, v0, zero
              sw a1, $0540(s0)
              sw t8, $0fcc(s0)
              sw zero, $0000(s1)
              beq zero, zero, $0001
              nop
              lw ra, $0040(sp)
              lw s3, $0030(sp)
              lw s2, $0020(sp)
              lw s1, $0010(sp)
              lw s0, $0000(sp)
              jr ra
              addiu sp, sp, $0040
              address $0044F15C
              
              dsra32 ra, zero, 31
              address $002CED04
              
              jr ra
              address $00599110
              Yeah would be possible to shorten the code. Not the best at coding lol, I finally had it working this version. Will look at shortening

              Comment


              • #8
                Just shorted the code quite a bit.

                Comment


                • #9
                  v1.3 shortened the code even more. Timer is less glitchy.

                  Comment

                  Working...
                  X