Issue with b_create_melee

VDfreesince1983

New member
This might just be a engine script oversight on my part. I use the b_create_melee script for a player attack for a platformer, my Melee object is in spot 01 (2) in the game object section, its animation is set to 00 (1) in its object details, but the script errors out during the compiling process

Routines\Basic\ModuleScripts\InputScripts\b_create_melee.asm(56):CreateObject(36): Unknown label.
Routines\Basic\ModuleScripts\InputScripts\b_create_melee.asm(73):CreateObject(36): Unknown label.

I cant find any issue with either line 56 or 73

CreateObject temp, temp1, #$01, #$00
CreateObject temp, temp1, #$02, #$00 ; I have tried switching those values around to 01 and 00

Aside from Dale_Coop's custom script for 4.0.11 this is almost identical to what worked in previous versions. I might have a simple (almost code free) solution for the Astynax-esque weapon arcs I have been working on, If I can get over this little Hiccup. Here is the entire script:

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
AND #%00000010 ;; this will be 0 on up and down, but 1 on left right
BNE createLRmelee
LDA temp2
TAY
LDA temp
SEC
SBC #$08 ;; width of weapon
CLC
ADC weaponOffsetTableX,y
STA temp
LDA temp1
SEC
SBC #$10
CLC
ADC weaponOffsetTableY,y
STA temp1

CreateObject temp, temp1, #$01, #$00
JMP meleeCreated
createLRmelee:
LDA temp2
TAY
LDA temp
SEC
SBC #$10 ;; width of weapon
CLC
ADC projOffsetTableX,y
STA temp
LDA temp1
SEC
SBC #$08
CLC
ADC projOffsetTableY,y
STA temp1
CreateObject temp, temp1, #$01, #$00
meleeCreated:
;;;; x is now the newly created object's x.
LDA Object_movement,x
ORA temp2
STA Object_movement,x
PlaySound #sfx_slash
doneAttacking:

RTS


;;000 down
;010 right
;100 up
;110 left
 

Mugi

Member
well, starting from the fact that if you're using 4.1.0, you need a new argument for CreateObject.

Code:
MACRO CreateObject arg0, arg1, arg2, arg3, arg4  ;; arg 3 = action step?
	
	;arg0 x value
	;arg1 y value
	;arg2 object type
	;arg3 action step - great for creating a 'spawning' effect that is non-zero
						;; or even for creating projectiles that may behave differently, where
						;; a single projectile could have 8 action types that are different, and 
						;; could load that particular action step, which could show a unique animation
						;; with specialized behaviors?  Just a thought.
	; arg 4 - Object_scroll (nametable...current, left or right)

as you see, it now required arg4 (scrolling control)
which is missing from yours (CreateObject temp, temp1, #$01, #$00)
 

VDfreesince1983

New member
Hehe, got frustrated and gave up, I'll try again later. Its really easy to get everything all mixed up and have no idea what you are doing anymore.
 

Mugi

Member
Im not really sure how that works either, havent done weapons on my game on 4.1.0 yet.
there was a video Joe made though, which used a melee sword in a scrolling platformer, maybe that will light up a little of how it was done. Might be worth to check.
 

dale_coop

Moderator
Staff member
Yeah, I tried that script (b_create_melee), adding the code to make it compile...
Code:
	LDA Object_scroll,x
   	STA temp3
	CreateObject temp, temp1, #$01, #$00, temp3

but with my scrolling platform game, the melee is strange (I wanted to use a projectile, but it doesn't move, I need to digit the code... maybe a conflict with the "ignore gravity" flag).

Joe used a weapon in its tutorial, but thesword is not an game object, it's "just" a sprite (there is user constant "SPR_WEAPON", in the project settings, to set it)... and the module uses the Sprite Pre-Draw script to make appearing when needed.
It's quite unusual :p
 

Mugi

Member
kinda makes sense though, to not waste a game object on that.
i need to experiment with that for saving some of the object space (my player sprite literally ate my whole gameobjects bank.) i already had to move my sprite hud into the monster bank :p
 

VDfreesince1983

New member
Yeah, I actually tried the same thing Dale did and got the same results, I was able to line up the object correctly tho, but it didn't move. I thought maybe you could change the x y coordinates to match the players but that didn't work. My initial idea was to so the weapon swing as a series of timed draw events instead of an animation. That way you don't have any junk sprites around the player. I was going to try to align each object with my player animation sync the times and then maybe translate it onto a plug in that could generate the Melee script with the GUI interface more easily. But I can't even get the basic Melee working so I switched my attention to the player hurt animation and opened a can of worms on that one as well.
 

Goaterby

Member
VDfreesince1983 said:
Yeah, I actually tried the same thing Dale did and got the same results, I was able to line up the object correctly tho, but it didn't move. I thought maybe you could change the x y coordinates to match the players but that didn't work... ...But I can't even get the basic Melee working so I switched my attention to the player hurt animation and opened a can of worms on that one as well.

Dang, you and me both. I can't even get the shooter example with the create projectile / melee script working from the video without it throwing an undefined label error. Maybe there is smoething going on behind the scenes or something, as Joe has it working in the video with no changes whatsoever.
 

dale_coop

Moderator
Staff member
Joe didn't use projectile... his player has a weapon, that is not an game object, it is a pre-defined sprite (of the tileset), it's set in the Project Settings > User Constants (SPR_WEAPON) and this sprite is pre-drawn (next to the Player Object) on certain circumstances (when player as flags activated).
In the adventure module it works well (I think the script should work well) because there is no gravity.
I might find how to fix that, diggin' in the code (when I can find free time :p)
And others scripts need to be tested, because there might some that could work better.
 

TurtleRescueNES

Active member
Following. I'm trying to do the same thing here for my adventure game. I had a variable 2-sprite melee weapon in 4.0.6, but that won't work in 4.1. I'm trying to replace the DrawSprite with the CreateObject so I can restore my old weapon, but haven't gotten the code to work yet.
 

Mugi

Member
maybe you guys should try to use the a_create_projectile.asm or b_create_proj_simple.asm (from Routines\Basic\ModuleScripts\InputScripts)if you're trying to create a shooting weapon.
i took a quick look and they seem to behave a little different from how it was in 4.0.11, and there's for example, this: CreateObject temp, temp1, #OBJECT_PLAYER_PROJECTILE, #$00, temp3
which is using a new variable, player projectile.
 

dale_coop

Moderator
Staff member
I think the "ignore gravity" flag deactivate all movements (horizontaly and verticaly).
Didn't take the time to test the others scripts yet... Will try tomorrow (sunday, maybe my kid and wife will give me some free time :p ...hoping)
 

dale_coop

Moderator
Staff member
Ok, I think I have my projectiles working...

Shoot.gif
 

VDfreesince1983

New member
jsherman Could you post your old code that uses the Draw Sprite command, I was reading a bit about that function and was curious what it would look like in this instance (even if it doesn't work with 4.1).
 
Top Bottom