Change Monster Action Step

tbizzle

Well-known member
I'd like a tutorial on how to have a Monster Object start in a different action step based a UserScreenByte being set. I've been trying to think how to do this and have been stumped so far. It is for a pickup. Each action step for this pickup has a different animation. Also each animation gives something different for what action step it is in within my pickup script (key, coin, ammo, etc.)
 

dale_coop

Moderator
Staff member
You need to add the code in a script that is executed when a screen loads...
(I'd suggest the Post Screen Load script... but if you don't have that screen, you could use doLoadScreen or doLoadScreen16 ...)
The code needs to be adjusted, depedning of how you use that screenByte... and which screenbyte? Is the screenbyte value the action step to use? or do you need to set the action step if the screenbyte is a certain value...? also is this any pickup objects ? or only certain objects IDs?

For example:
Code:
LDX #$00
-loopObj:
  LDA Object_status,x
  AND #%11000000    ;; if object is actif
  BEQ +nextObj

    STX temp  ;; here important 
 
    LDA Object_type,x
    CMP #04  ;; if object #4
    BNE +notThatObject
        ;; it is that object:
        ChangeActionStep temp, screenByte  ;; change to action step value defined by the "screenByte"
        JMP +nextObj
    +notThatObject:

    ;; OR YOU COULD DO, ENY PICKUPS:
    LDA Object_flags,x
    AND #%00100000  ;; if a "pickup" object
    BEQ +notPickupObj
        ;; it is a pickup object:
        ChangeActionStep temp, screenByte  ;; change to action step value defined by the "screenByte"
        JMP +nextObj
    +notPickupObj:

  +nextObj:
INX
CPX #TOTAL_MAX_OBJECTS
BNE -loopObj
 
Last edited:

tbizzle

Well-known member
@dale_coop This was my initial idea.

Code:
LDA userScreenByte3
CMP #255
BEQ doChange
JMP nextChange
    doChange:
    ChangeActionStep #39, #1
JMP noCanDo
    nextChange:
    
LDA userScreenByte3
CMP #254
BEQ doChange1
JMP nextChange1
    doChange1:
    ChangeActionStep #39, #2
JMP noCanDo
    nextChange1:
    
LDA userScreenByte3
CMP #253
BEQ doChange2
JMP nextChange2
    doChange2:
    ChangeActionStep #39, #3
JMP noCanDo
    nextChange2:
    
LDA userScreenByte3
CMP #252
BEQ doChange3
JMP nextChange3
    doChange3:
    ChangeActionStep #39, #4
JMP noCanDo
    nextChange3:
    
LDA userScreenByte3
CMP #251
BEQ doChange4
JMP nextChange4
    doChange4:
    ChangeActionStep #39, #5
JMP noCanDo
    nextChange4:
    
LDA userScreenByte3
CMP #250
BEQ doChange5
JMP nextChange5
    doChange5:
    ChangeActionStep #39, #6
JMP noCanDo
    nextChange5:
    
LDA userScreenByte3
CMP #249
BEQ doChange6
JMP nextChange6
    doChange6:
    ChangeActionStep #39, #7
    nextChange6:
    noCanDo:
 

dale_coop

Moderator
Staff member
@dale_coop This was my initial idea.

Code:
LDA userScreenByte3
CMP #255
BEQ doChange
JMP nextChange
    doChange:
    ChangeActionStep #39, #1
JMP noCanDo
    nextChange:
   
LDA userScreenByte3
CMP #254
BEQ doChange1
JMP nextChange1
    doChange1:
    ChangeActionStep #39, #2
JMP noCanDo
    nextChange1:
   
LDA userScreenByte3
CMP #253
BEQ doChange2
JMP nextChange2
    doChange2:
    ChangeActionStep #39, #3
JMP noCanDo
    nextChange2:
   
LDA userScreenByte3
CMP #252
BEQ doChange3
JMP nextChange3
    doChange3:
    ChangeActionStep #39, #4
JMP noCanDo
    nextChange3:
   
LDA userScreenByte3
CMP #251
BEQ doChange4
JMP nextChange4
    doChange4:
    ChangeActionStep #39, #5
JMP noCanDo
    nextChange4:
   
LDA userScreenByte3
CMP #250
BEQ doChange5
JMP nextChange5
    doChange5:
    ChangeActionStep #39, #6
JMP noCanDo
    nextChange5:
   
LDA userScreenByte3
CMP #249
BEQ doChange6
JMP nextChange6
    doChange6:
    ChangeActionStep #39, #7
    nextChange6:
    noCanDo:
be carefull... you need to put all this code in a LOOP through all the objects, like I wrote.

And your "ChangeActionStep #39, #1"
needs to be replacd by
Code:
STX temp
ChangeActionStep temp, #1
 

dale_coop

Moderator
Staff member
@dale_coop This was my initial idea.

Code:
LDA userScreenByte3
CMP #255
BEQ doChange
JMP nextChange
    doChange:
    ChangeActionStep #39, #1
JMP noCanDo
    nextChange:
   
LDA userScreenByte3
CMP #254
BEQ doChange1
JMP nextChange1
    doChange1:
    ChangeActionStep #39, #2
JMP noCanDo
    nextChange1:
   
LDA userScreenByte3
CMP #253
BEQ doChange2
JMP nextChange2
    doChange2:
    ChangeActionStep #39, #3
JMP noCanDo
    nextChange2:
   
LDA userScreenByte3
CMP #252
BEQ doChange3
JMP nextChange3
    doChange3:
    ChangeActionStep #39, #4
JMP noCanDo
    nextChange3:
   
LDA userScreenByte3
CMP #251
BEQ doChange4
JMP nextChange4
    doChange4:
    ChangeActionStep #39, #5
JMP noCanDo
    nextChange4:
   
LDA userScreenByte3
CMP #250
BEQ doChange5
JMP nextChange5
    doChange5:
    ChangeActionStep #39, #6
JMP noCanDo
    nextChange5:
   
LDA userScreenByte3
CMP #249
BEQ doChange6
JMP nextChange6
    doChange6:
    ChangeActionStep #39, #7
    nextChange6:
    noCanDo:

Then, the code should be something like that:

Code:
LDX #$00
-loopObj:
  LDA Object_status,x
  AND #%11000000    ;; if object is actif
  BEQ +nextObj

    LDA Object_type,x
    CMP #39  ;; if object #39
    BNE +notThatObject

        LDA userScreenByte3
        CMP #255
        BNE +notThatOne
            LDA #1
            STA tempA
            JMP +canDo
        +notThatOne:
        
        LDA userScreenByte3
        CMP #254
        BNE +notThatOne
            LDA #2
            STA tempA
            JMP +canDo
        +notThatOne:
        
        LDA userScreenByte3
        CMP #253
        BNE +notThatOne
            LDA #3
            STA tempA
            JMP +canDo
        +notThatOne:
        
        LDA userScreenByte3
        CMP #252
        BNE +notThatOne
            LDA #4
            STA tempA
            JMP +canDo
        +notThatOne:
        
        LDA userScreenByte3
        CMP #251
        BNE +notThatOne
            LDA #5
            STA tempA
            JMP +canDo
        +notThatOne:
        
        LDA userScreenByte3
        CMP #250
        BNE +notThatOne
            LDA #6
            STA tempA
            JMP +canDo
        +notThatOne:
        
        LDA userScreenByte3
        CMP #249
        BNE +notThatOne
            LDA #7
            STA tempA
            JMP +canDo
        +notThatOne:

            JMP +notThatObject

        +canDo:

        STX temp  ;; here important
        ChangeActionStep temp, tempA  ;; change to action step value defined by the "screenByte"
        
    +notThatObject:
  +nextObj:
INX
CPX #TOTAL_MAX_OBJECTS
BNE -loopObj
 

tbizzle

Well-known member
@dale_coop It works perfectly! All I had to do is make one small adjustment! THANK YOU!!!!!!!!!!!!!!!!

Code:
CPX #TOTAL_MAX_OBJECTS
BEQ audi5000
JMP -loopObj
    audi5000:
 

tbizzle

Well-known member
@dale_coop The only thing I noticed was that only action step 0 will play its animation. Action steps 1-7 won't do any animations. Other than that it works great!
 

Gator83

Member
Trying to change a monsters bounding box for different action steps. I need no collision between player & monster for certain steps. Not quite sure how to go about that yet, but I thought maybe Object collisions but I've had no luck yet. Not sure if this thread is in the right direction?
 

baardbi

Well-known member
No.
Trying to change a monsters bounding box for different action steps. I need no collision between player & monster for certain steps. Not quite sure how to go about that yet, but I thought maybe Object collisions but I've had no luck yet. Not sure if this thread is in the right direction?
No. This is not the correct thread for that. Take a look at this instead. That will help you get started.

 

SHLIM

Active member
I'd like a tutorial on how to have a Monster Object start in a different action step based a UserScreenByte being set. I've been trying to think how to do this and have been stumped so far. It is for a pickup. Each action step for this pickup has a different animation. Also each animation gives something different for what action step it is in within my pickup script (key, coin, ammo, etc.)
ive done something similar but how i did it was i made my objects step 0 blank and then execute a action script which determines which step to jump to!
 
Top Bottom