Make player object damage enemy?

Looking for a way to make my player object damage the enemy when they come into contact in certain instances.
Think possibly like the star powerup in Super Mario Bros.

My player doesn't have a melee weapon, but they do have a neat kick animation.
I was wondering if there was a way to set by code(preferably) or by the interface where the player damages the enemy when you run into them instead of the enemy damaging the player.
I didn't want to use the melee weapon, because my sprite will be moving too quickly for the player to accurately hit an enemy with part of the sprite. I just want to make contact with any part of the sprite damage the enemy.
 

chronosv2

New member
I believe this could actually be done using action flags, if all the states where the character is doing a melee attack are action states.
You could have an "Invincible" flag turn on for the player and a "Harm Enemies" flag. Then in the code for collisions you'd check if "Harm Enemy" was turned on and if so damage the enemy. Could use very similar code to "Head bounce kills" code, just without the bounceback..
 
The jump kick is 2 steps:

1: a standard jump bound to my B button. Nothing special.

2: Special ability triggered with DOWN + B
I went over how I implemented equippable special abilities in this thread:
http://nesmakers.com/viewtopic.php?f=3&t=936

Specifically my dash code is just modified jump code to point left or right.
I have added a bit extra to check facing direction and change action step.
Here you go:
Code:
;; SPECIAL MOVE: AIRDASH-----------------------------
specialMoveAirDash:
;; Setup Melee Weapon Effect
  
    ;; Check if the player is already dashing, and skip if so
    LDX player1_object
    GetCurrentActionType player1_object
    CMP #$07
    BEQ dontairDash

    ;; Check facing direction
    LDA Object_movement,x
    AND #%00000111 ;only keep the last 3 bits
    CMP #%00000010 ;FACE_RIGHT      = #%00000010
    BEQ airDashRight
    JMP airDashLeft

airDashRight:
    ;FACE_RIGHT     = #%00000010
    LDA #$00
    ADC #$04
    STA Object_h_speed_hi,x
    JMP continueSliding

airDashLeft:
    ;FACE_LEFT      = #%00000110
    ;; Store 250 in accumulator and assign it to object's speed
    LDA #$00
    SBC #$05
    STA Object_h_speed_hi,x

continueairDash:
    ChangeObjectState #$07, #$02 ;Set the object's animation state (my dash action is 7)
    ;PlaySound #SFX_PLAYER_JUMP
    
dontairDash:
    JMP +

;; Setup Melee Weapon Effect
is where I plan to set the flag to make the player damage enemy from the kick. Right now it is just movement.

I set it up this way so my player can have more 'moves' than what the NES controller limits them to.
With the equippable special moves you have an additional 8 'move' slots, you just can only have 1 of them equipped at a time.
And that is if you do not make another combo like UP + B with a similar script.
Though truthfully I am not sure how much space my code is taking up.
 
I dug into the object collisions and found where it checks the objects flags and chooses an action based on that.

I modified this bit from the script 'HandleObjectCollisions_Platform_Simple.asm' line 151+

Code:
yesPlayerObjectCollision:
    ;; Check if the player we collided with is in an attacking state
    TXA
    STA tempx
    LDX player1_object
    LDA Object_vulnerability,x
    AND #%00100000 ;; NEW Player's attacking flag
    BEQ doPlayerHurtEnemy
    LDX tempx ;; If not return things to the way they were.

	LDA Object_vulnerability,x
	AND #%00000010 ;; in this module, this is ignore player collision
	BEQ doPlayerHurt
	JMP	noPlayerObjectCollision  
doPlayerHurtEnemy:
    TXA
	PHA
	.include SCR_HANDLE_HURT_MONSTER
	PLA
	TAX
	;;; if monster dies, count monsters
	;; right now, he always dies, so count the monsters.
	JSR countAllMonsters	
    JMP playerWasNotHurtDuringCollision

It looks like I do not understand enough about what is going on here though, because this just gives me compiler errors.
It seems I cannot include SCR_HANDLE_HURT_MONSTER a second time.
So how would I jump to the code that hurts the monster?
 
The jump kick is 2 steps:

1: a standard jump bound to my B button. Nothing special.

2: Special ability triggered with DOWN + B
I went over how I implemented equippable special abilities in this thread:
http://nesmakers.com/viewtopic.php?f=3&t=936

Specifically my dash code is just modified jump code to point left or right.
I have added a bit extra to check facing direction and change action step.
Here you go:
Code:
;; SPECIAL MOVE: AIRDASH-----------------------------
specialMoveAirDash:
;; Setup Melee Weapon Effect
 
    ;; Check if the player is already dashing, and skip if so
    LDX player1_object
    GetCurrentActionType player1_object
    CMP #$07
    BEQ dontairDash

    ;; Check facing direction
    LDA Object_movement,x
    AND #%00000111 ;only keep the last 3 bits
    CMP #%00000010 ;FACE_RIGHT      = #%00000010
    BEQ airDashRight
    JMP airDashLeft

airDashRight:
    ;FACE_RIGHT     = #%00000010
    LDA #$00
    ADC #$04
    STA Object_h_speed_hi,x
    JMP continueSliding

airDashLeft:
    ;FACE_LEFT      = #%00000110
    ;; Store 250 in accumulator and assign it to object's speed
    LDA #$00
    SBC #$05
    STA Object_h_speed_hi,x

continueairDash:
    ChangeObjectState #$07, #$02 ;Set the object's animation state (my dash action is 7)
    ;PlaySound #SFX_PLAYER_JUMP
   
dontairDash:
    JMP +

;; Setup Melee Weapon Effect
is where I plan to set the flag to make the player damage enemy from the kick. Right now it is just movement.

I set it up this way so my player can have more 'moves' than what the NES controller limits them to.
With the equippable special moves you have an additional 8 'move' slots, you just can only have 1 of them equipped at a time.
And that is if you do not make another combo like UP + B with a similar script.
Though truthfully I am not sure how much space my code is taking up.
Where do I put this script? looks fantastic. Congratulations
 
Top Bottom