4.1.5 Adventure Module, Melee combat object not working.

JustDock

New member
I'm having issues with setting up the melee attack with version 4.1.5 after watching the 3 hour adventure module tutorial. Both melee and projectile source are correctly set up, but when I export and test my game, the player sprite plays its attack animation, but the sword doesn't appear.
 

dale_coop

Moderator
Staff member
By default, in the 4.1.5, your Melee weapon is not a game object. It's a sprite (a 8x8tile from your GameObjectTiles.bmp) drawned next to the Player object, when he's in "attacking" state.
The sprite based sword is defined by two user constants (in "Project Settings > User Constants") SPR_WEAPON_V and SPR_WEAPON_H for the index of the tile to draw when the player is facing vertically / horizontally:

2019-07-10-09-20-52-NES-MAKER-4-1-5-Version-0x159-Basic-Adv-MST.png
 

acaudel

Member
Thank you dale_coop for this info! I was having this same problem. I didn't see this info in any of the tutorial videos.
Does this mean that the melee object can only be one tile?
 

dale_coop

Moderator
Staff member
If you use the sprite based weapon, basically yes
If you need a bigger weapon or animated, you might have to use a object.
Cf the tutorial I wrote, in the Community Tutorials section: http://nesmakers.com/viewtopic.php?f=35&t=1777
 

Mugi

Member
sprite weapons can be made larger (and animated) but that involves quite a series of conditions to be written into predraw where the drawing of the sprite weapon happens,
it's preferable that you branch the weapon draw code out of predraw and jsr into it if you're going to explore with that.

that said, silver island uses multiple sprite weapons of different shapes and sizes, some animated, some not. I wrote the framework for that so i know it can definitely be done.
(no, i dont have the code for it anymore.)
 
acaudel said:
dale_coop & Mugi, thank you for the info! I'll look into it and see if I can get it to work! :)

Did you get this working yet? I'm trying to make an Adventure-module 4.1.5 game, and I also am very frustrated that the weapon does not work the way the Adventure tutorial claims it does. I've made my Horizontal and Vertical attack objects, matched them to my Player's attack animation, and tried YouTube and the forums for an answer, but no luck.

I looked at https://nesmakers.com/viewtopic.php?f=35&t=1777, but it's only Horizontal and intended for the Platformer module. This thread https://nesmakers.com/viewtopic.php?f=60&t=3817 was addressing using the previous thread in the Adventure module, but all it says is the user got it working - not how. I tried copy/pasting the code, and it wasn't working.

I also have to say, after stumbling across this thread https://nesmakers.com/viewtopic.php?f=60&t=3775 and reading that the melee weapon is now a one-hit-kill, I'm not happy. That does not seem a reasonable decision to make.

I'm OK with needing to code, but the fact that NESmaker is advertised as "no coding necessary" then ships with buggy code is displeasing; I really hope 5.0 fixes a LOT of this. Sorry I got long-winded; long story short, I just want to use my Melee Attack objects, like the tutorial.

Thank you.
 

dale_coop

Moderator
Staff member
Hmm... for the adventure module, I guess it's the same than the tutorial : https://nesmakers.com/viewtopic.php?f=35&t=1777
except those points:
2) the "b_create_melee_weapon.asm" script would be something like:
Code:
	LDA gameHandler
	AND #%00100000
	BEQ notNPCstate_attack
	JMP doneAttacking
notNPCstate_attack:
	 LDA weaponsUnlocked
	 AND #%00000001
	 BNE canAttack
	 JMP doneAttacking
canAttack:
	LDX player1_object
	GetCurrentActionType player1_object
	CMP #$02
	BNE notAlreadyAttacking 
	JMP doneAttacking
	
notAlreadyAttacking:
	;;; don't attack if already attacking.
	;;; do we have to check for hurt here?
	;;;;; Here, we WOULD create melee
	ChangeObjectState #$02, #$02
	LDA Object_movement,x
	AND #%00001111
	STA Object_movement,x
	LDA #$00
	STA Object_h_speed_hi,x
	STA Object_h_speed_lo,x
	STA Object_v_speed_hi,x
	STA Object_v_speed_lo,x

	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1

	LDA Object_movement,x
	AND #%00000111
	STA temp2
	TAY

	LDA Object_x_hi,x
	SEC 
	SBC #$08	;; <<--- HERE, you have to set width of melee weapon in HEX (1 tile = 8px, 8 in decimal = #$08 in hex. Use the binary <-> hex converter plugin)
	STA temp
	LDA Object_scroll,x
	SBC #$00
	STA temp3

	LDA temp
	;;; offset x for creation
	CLC
	ADC weaponOffsetTableX,y
	STA temp
	LDA temp3
	ADC #$00
	STA temp3

	LDA Object_y_hi,x
	CLC
	ADC weaponOffsetTableY,y
	SEC
	SBC #$08	;; <<--- HERE, you have to set height of melee weapon in HEX (1 tile = 8px, 8 in decimal = #$08 in hex. Use the binary <-> hex converter plugin)
	STA temp1	
	
	CreateObject temp, temp1, #OBJECT_PLAYER_MELEE, #$00, temp3
	
meleeCreated:
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
	
    ;PlaySound #SND_SLASH
	
doneAttacking:
	RTS

4) This would not be the "Action Step 3" but the "Action Step 2" (Because in the Adventure module, the attacking state is actually the "Action Step 2").
 
Top Bottom