[4.5.9] Brawler - Different Enemies and Attacks

offparkway

Active member
Howdy!

Working with the brawler engine, and I'm a bit lost as to how to create different monsters that have their own attacks. The attack script seems to be Bank 18 (?), which pulls the "fist" item from slot #$11 in enemyPunch. Seems like a lot of code o try to repeat for every enemy.

Could someone give me an example of how I might make a new enemy with a different attack object?
 

mouse spirit

Well-known member
Can you make the object have a transparent graphic? That way you can have the baddie do whatever.
Or do a screentype check? Like If on screentype 1, use this object or look like this graphic and so on.
 

offparkway

Active member
Can you make the object have a transparent graphic? That way you can have the baddie do whatever.
Or do a screentype check? Like If on screentype 1, use this object or look like this graphic and so on.
I actually just figured out a way, by creating a new action type (BossPunch, in my case) and setting it up that way. It works great, and I just needed to adjust the x and y for the weapon I created.

The issue I’m having now is that my boss is wider than 10 pixels, and the module seems to be set up for monsters with 10 . So the animations work fine, and the monster attacks Left just fine, but when he attacks to the right he overshoots me because the game thinks it's a smaller enemy... a default-sized monster. Dunno how to increase the hit box to match the monster's size.

I made sure the monster has a huge bounding box, but it made no difference.
 
Last edited:

puppydrum64

Active member
There's a few ways. The AI Behaviors for attacking can simply call subroutines in Bank 18, you can always add new ones there. Here's an example of one I did where I added a gun for monsters to use.

Code:
doEnemyShoot:
    TXA
    PHA
    LDA Object_direction,x
    AND #%00000111
    STA tempz ;; direction hold
    CMP #%00000110
    BNE +mustBeRightAttack
        ;; must be left attack
        LDA Object_x_hi,x
        SEC
        SBC #$08 ;; width of monster throwing the punch.
            ;; presumes all monsters are #$10 wide.
        STA tempA
        LDA Object_screen,x
        SBC #$00
        STA tempD ;; the screen it should appear on.
  
        LDA Object_y_hi,x
        CLC
        ADC #$08
        STA tempB
  
        LDA #$12 ; this is specific to my program, change this to whatever monster the gun is
        STA tempC ;; the object that should appear.
        JMP +createGun

    +mustBeRightAttack:
        LDA Object_x_hi,x
        CLC
        ADC #$10 ;; width of monster throwing the punch.
            ;; presumes all monsters are #$10 wide.
        STA tempA
        LDA Object_screen,x
        ADC #$00
        STA tempD ;; the screen it should appear on.
  
        LDA Object_y_hi,x
        CLC
        ADC #$08
        STA tempB
  
        LDA #$12 ; this is specific to my program, change this to whatever monster the gun is
        STA tempC ;; the object that should appear.
    +createGun:
    CreateObjectOnScreen tempA, tempB, tempC, #$00, tempD ;create gun
        LDA tempz
        STA Object_direction,x
        CreateObjectOnScreen tempA, tempB, #$03, #$00, tempD ;create bullet, assumes bullet is game object 03
        LDA tempz
        STA Object_direction,x
        JMP +done
  

    +done
    PLA
    TAX
    RTS

Afterwards simply create an AI Behavior that says the following:

Code:
SwitchBank #$18
JSR doEnemyShoot
ReturnBank

Feel free to copy/paste this code into your Bank 18 if you wish. No credit needed, since I mostly just copy/pasted the original anyway.
 
Last edited:
Top Bottom