[4.1] Use the real Melee object weapon in the Platformer module

Right now, it looks like the b melee script for adventure module handles text boxes and melee weapon (which makes sense, given that the b button handles both of these things). Can the b melee script you posted here be easily incorporated with that, so that the b button still handles melee and text boxes?
 

dale_coop

Moderator
Staff member
Yep, could be possible...

Or you could make a "b_activate_text_box.asm" script, that does only that (activate the npc text box) and assign this script the "press" "B" button, too:

Code:
	LDA textboxHandler
	AND #%00010000 ;; if the b button is pressed
					;; but the box + text have been activated
					;; and also the 'do box' bit is OFF
					;; that means this is ready to "go away".
					
	BEQ checkToTurnTheTextboxOn ;; hasn't started yet
    
    ;; begin turning the textbox off.
    LDA gameHandler
    ORA #%00100000
    STA gameHandler
    ;;; are we turning this on or off?
    ;;; check for more
    ;;; check for 'choice'.
  
    LDA #$00
    STA updateNT_offset
    STA updateNT_H_offset
    STA updateNT_V_offset
    
    LDA #%10001000
    STA textboxHandler
    RTS
   
checkToTurnTheTextboxOn:  
   LDA npc_collision
    BEQ noNPCcollision
    LDA textboxHandler
    AND #%10000000
    BNE noNPCcollision
   LDA gameHandler
    ORA #%00100000
    STA gameHandler
    ;;; are we turning this on or off?
    ;;; check for more
    ;;; check for 'choice'.

turnTheTextboxOn:
  
    LDA #%10000000
    STA textboxHandler
    
noNPCcollision:
    RTS
 

torseelos

New member
The Object Weapon works fine for me - Thank You! I still have two issues left:

1) I don't know where to add Nate's Script in the PreDraw DC. If I just put it at the end, it tells me, a label in line 75 was unwritten. This line is " LDX #OBJ_PLAYER_MELEE" for me.

2) My Melee to the right has two Animationframes with double the speed than my left.

Thanks =)
 

dale_coop

Moderator
Staff member
For your 1) try change the
LDX #OBJ_PLAYER_MELEE
with
LDX #OBJECT_PLAYER_MELEE

For your 2) strange... I will try to reproduce.
 

rimoJO

Member
The script works for me, but all of the letters are replaced with their corresponding numbers. ???
EDIT: For the text part. I'm using the 4.latest version platform module.
 

Attachments

  • Screenshot (13).png
    Screenshot (13).png
    67.4 KB · Views: 3,904

dale_coop

Moderator
Staff member
Check again your hud tiles. Set again the letters. And the numbers.
(When you set the number, select the 0. When you set letters, select the A)
 
Dale great code. Nate great addition to code. Both codes worked well for me, until I tired using Nate's addition code in conjunction with the Joe Sherman's Bee Spawning code. It became problematic with the Bee Spawning code. Spawners were following my character and spawning enemies parallel to my player and getting stuck on solid tiles my player was walking on. Has anyone had success using Dale, Nate, and Joe's codes together?
 

dale_coop

Moderator
Staff member
It might another name depending of the module used... Might be named “sprite based weapon” or “handle sprite weapon” or something like that.

Update: confirmed, in the adventure module, it is labeled "Handle Sprite Weapon" in the "Project Settings > Script Settings".
 

Craigery

Active member
Dale, how does the Monster Object get destroyed? There is a line in HandleSpriteWeapon.asm which included a DeactivateCurrentObject on the monster object, but we remove that. So how does it get destroyed here?
 

dale_coop

Moderator
Staff member
Craigery... when the melee weapon was a sprite.. all the code for collision with a monster was in the HandleSpriteWeapon.asm script.
Now that the weapon is a real object, it follows the rules of object collisions (HandleObjectCollisions.asm script) and in that script, when a "player weapon" type object collides with a "monster" type object, the Handle Monster Hurt script is executed.
So, in that script, your monster will be destroyed (cf. your HandleHurtMonster.asm script you will find the DeactivateCurrentObject that is used now).
 

drexegar

Member
Thank you. I spent far too long messing with the create object code, (the stop player action doesn't work and the offset doesn't work) so I just follow your tutorial and it works great in the scrolling platform!
 

angelcrusher

New member
Hi everyone! Thanks for all of the tips. I'm using these scripts in a side scrolling platformer and everything works great with the PreDraw tweaks, but once I insert objects into my screen they are pulled towards my player when running the activate melee script. Seems to only happen when running the PreDraw tweaks for having the object follow the player in mid movement/air.

Has you seen this?

I've tried with monsters and with power-up objects and messed around with the code for a little bit. I'm just not so great with assembly since I just started learning.
 

dale_coop

Moderator
Staff member
angelcrusher said:
Hi everyone! Thanks for all of the tips. I'm using these scripts in a side scrolling platformer and everything works great with the PreDraw tweaks, but once I insert objects into my screen they are pulled towards my player when running the activate melee script. Seems to only happen when running the PreDraw tweaks for having the object follow the player in mid movement/air.

Has you seen this?

I've tried with monsters and with power-up objects and messed around with the code for a little bit. I'm just not so great with assembly since I just started learning.

Hey angelcrusher, I think the PreDraw code proposed by Nate might be working for the particular case of Nate's project, but it's really useable as it.
I would suggest you to remove that part if your added it. And just set a timer to "DestroyMe" for your Player's Weapon for the Action Step 0 like specified in the original post.... until a more appropriate parenting code (weapon following the player) with a tutorial is made.
 

Rancor

New member
I think I got SuperNatetendo's code to kinda work (for me, at least). There are some strange issues connected to player death (specifically being killed by monsters) for some reason, but so far things are looking good up until then. I should mention that my weapon has 2 action states, though - and that part of the code that checks for it being in the 00 state is what got the script to stop jockeying monsters on top of me whenever I entered the room. Even so, it appears sometimes they can still latch on to you, but it:
1.) is much less common,
2.) is only temporary, and
3.) only occurs in very specific circumstances (using the melee attack right in-between 2 screens, I think - which likely has a simple solution that I am unaware of).
Anyways, here's what I could patch together:
Code:
;; Nate's now slightly less-janky object parenting w/ melee weapon

    GetCurrentActionType player1_weapon 	;; Checking if the weapon is in action type 00...
    CMP #$00
    BEQ +++						;; If so, skip this whole business...
    
    LDX player1_object
   
    LDA Object_animation_frame,x
    STA temp
    
    LDA Object_movement,x
    AND #%00000111
    STA temp3
    TAY

    CLC
    CMP #$04 	;;If it if four or greater, you are facing right. (Some code taken from Dieting Hippo's melee script, checks which direction you are facing and draws the sprite accordingly)
    BCS + 		;; if carry flag is set, jump to our nameless label
    LDA Object_x_hi,x
    SEC
    SBC #$00	;; width of melee weapon (Right offset)
    JMP ++		; skip doing the left stuff
+
    LDA Object_x_hi,x
    SEC
    SBC #$1F	;; width of melee weapon (Left offset)
++
    CLC
    ADC weaponOffsetTableX,y
    STA temp1
    
    LDA Object_y_hi,x    
    CLC
    ADC weaponOffsetTableY,y
    SEC
    SBC #$08 ;; height of melee weapon
    STA temp2
    
    LDX player1_weapon
    LDA temp1
    STA Object_x_hi,x
    LDA temp2
    STA Object_y_hi,x
    
    LDA Object_movement,x
    ORA temp3
    STA Object_movement,x
+++
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
Top Bottom