S3: Making new objects react to others

Discussion in 'Discussion and Q&A Archive' started by Psi, Apr 15, 2015.

  1. Psi

    Psi Well-Known Member Member

    Joined:
    Dec 20, 2014
    Messages:
    102
    I've been trying to program in a projectile object into Sonic 3+K. While it's mostly working, I'm still having problems programming it to affect certain objects, the breakable wall/rock object likely being the most pivotal. Here's what I have in the ASM so far:

    loc_1FD4E:
    lea (Shield_P2).w,a1
    move.w $30(a0),d1
    move.w d6,d0
    andi.w #1,d0
    cmpi.l #Obj_Laser,(a1) ; if it's not sonic, branch all this stuff
    beq.w loc_1FDA4
    lea (Player_1).w,a1
    move.w $30(a0),d1
    move.w d6,d0
    andi.w #1,d0
    beq.w loc_1FDEA
    tst.b $2C(a0)
    bpl.s loc_1FD72
    cmpi.b #2,$38(a1)
    beq.s loc_1FDA4
    cmpi.l #Obj_Laser,(a1)
    beq.s loc_1FDA4
    cmpi.b #$24,$20(a1)
    beq.s loc_1FDA4
    bra.w loc_1FDEA
    ; ---------------------------------------------------------------------------
     
    loc_1FD72:
    tst.b (Super_Sonic_Knux_flag).w
    bne.s loc_1FDA4
    cmpi.b #2,$38(a1)
    beq.s loc_1FDA4
    btst #4,$2B(a1)
    bne.s loc_1FD90
    ;btst #5,$2A(a0)
    ;beq.s loc_1FDEA
    nop
     
    loc_1FD90:
    cmpi.l #Obj_Laser,(a1)
    beq.s loc_1FDA4
    cmpi.b #$24,$20(a1)
    beq.s loc_1FDA4
    cmpi.b #2,$20(a1)
    bne.s loc_1FDEA
    move.w d1,d0
    bpl.s loc_1FD9E
    neg.w d0
     
    loc_1FD9E:
    cmpi.w #$480,d0
    bcs.s loc_1FDEA
     
    loc_1FDA4:
     
    bclr #5,$2A(a0)
    bsr.w sub_1FE34
    btst #6,$2A(a0)
    beq.w loc_1FD38
    lea (Player_2).w,a1
    cmpi.b #2,$38(a1)
    beq.s loc_1FDCE
    cmpi.l #Obj_Laser,(a1)
    beq.s loc_1FDCE
    cmpi.b #$24,$20(a1)
    beq.s loc_1FDCE
    cmpi.b #2,$20(a1)
    bne.w loc_1FD38

    As you can see it's pretty messy due to not knowing whether to program it through player 1 or as a separate object (it loads through the Shield_P2 Object). Thus far I can make it break the object, however it only does so when the player is right up close to it. If the object has to move to reach the wall/rock, it doesn't affect it for reason. Anyone know the problem?
     
  2. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I'm have no idea how S3Ks wall object works (and very little about S3K object coding in general), but I know for a fact that in both S1 and S2, the wall object first checks if the player is actually touching the side of it before loading the breaking code; you'll have to build an extra check in the wall object itself to see if it's touching the projectile, then load the break routine. Again, this could be wrong, but I don't see why it would be.
     
    Last edited by a moderator: Apr 16, 2015
  3. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    What I usually do with things like this (after I've backed up the file first of course), is start deleting (commenting out) some branches and then build and test to see what happens; to help narrow down the issue. If it's not getting to the code you want it to, take the branches that makes it divert it away.

    Without some comments (and little S3K knowledge), I'm not sure what your code is for. This is more of a trial-and-error. This is how I do some things and it's great because I get to learn what each thing is then doing.
     
  4. Psi

    Psi Well-Known Member Member

    Joined:
    Dec 20, 2014
    Messages:
    102
    Basically the branches are supposed to recognise when the laser is touching the rock object and to branch over the player 1 and 2 data (eg. whether they are spinning or not) over to the coding which orders it to break.
     
    Last edited by a moderator: Apr 16, 2015