[Fixed] Monsters? Stealing MY offsets? It's more likely than you think.

Rancor

New member
Hey guys. Been having an issue lately where some monsters have been nabbing weapon offsets off of me for some reason.
Right now I'm using a code I got from the very helpful and talented Dieting Hippo on the discord, but this phenomena is also an occurrence while using SuperNatetendo's object parenting script (found in this thread:http://www.nesmakers.com/viewtopic.php?f=35&t=1777).
In SuperNatetendo's script, the monster just gets instantly glued to me and all kinds of horrible things happen when monsters are involved.
Using Dieting Hippo's script, some other interesting stuff happens, which I made a video on to document my findings (closed captions serve as a narration):
[media]https://www.youtube.com/watch?v=ucKEZZPSXkA[/media]

Just for some background, my weapon object has 2 action states (00,01), and the 00 action state is meant to act as a wind-up, whereas the 01 is the actual attack.
The action state 01 uses this script assigned to AI Action 11:
Code:
;; By Dieting Hippo from the NESmaker Discord
;; Makes your weapon move... for Simon Belmont-like reasons!
LDX player1_weapon
LDA Object_movement,x ;; A = movement flag (#$00-#$08)
CLC
CMP #$04 ;;If it if four or greater, you are facing right. 
BCS + ;; if carry flag is set, jump to our nameless label for subtraction
    ;; add facing right code here
    LDA Object_x_hi,x
    CLC
    ADC #$10 ;add your x offset here
    STA Object_x_hi,x
    LDA Object_y_hi,x
    CLC
    ADC #$00 ;add your y offset here
    STA Object_y_hi,x
    JMP ++
+
    ;;add facing left code here
    LDA Object_x_hi,x
    CLC
    SBC #$0F ;add your x offset here
    STA Object_x_hi,x
    LDA Object_y_hi,x
    CLC
    ADC #$00 ;add your y offset here
    STA Object_y_hi,x
++

As you can see in the video, the monsters in my game are quite fond of this script (as am I). Only issue is, I don't really want to share it with them. Anyone have any ideas?

EDIT: Dieting Hippo to the rescue again! If your setup is like mine, you'll have to make a small change to your b_create_melee_weapon.asm.
Around line 55-ish it should say "CreateObject" with a bunch of parameters attached to it. Add a new line under it that says "STX player1_weapon".
I've also modified the above script in the original post to work with this fix. A big thanks again to Dieting Hippo from the Discord!
 
Top Bottom