Crouching attack setup question

red moon

Member
I would like to hookup the attack action when crouching and wanted to ask what the proper method is for doing this. Do I setup an animation set in the same way I setup walking, jumping, shooting, attacking and crouching?
And since the input is taken by couch, is there a way to setup 2 inputs into the controller setup? Since the projectile action and melee action also share the same input, I am guessing I add another input for the low attack?
Thank you for taking the time to look at this!
 

Attachments

  • Crouch.jpg
    Crouch.jpg
    446 KB · Views: 983
  • crouchattack.jpg
    crouchattack.jpg
    435.4 KB · Views: 983
  • crouchinput.jpg
    crouchinput.jpg
    455.8 KB · Views: 983

dale_coop

Moderator
Staff member
I think... crouching attack, would be the same script than attack.
the only difference is the crunching direction (when you press Down, your player is in DOWN_LEFT or DOWN_RIGHT directions), so just assign your animations to those directions for the attach action step.
 

red moon

Member
I am closer at least! It seems that I am missing a step that connects the melee action to the correct sprite and corrects the facing of the melee object. Would this require a duplicate melee script that is altered to enable low attacks?

I'll place a couple screens here along with a video to show what I have happening...

https://youtu.be/H0uNEFl-JRo

Thanks!
 

Attachments

  • attack.jpg
    attack.jpg
    559.2 KB · Views: 919
  • input.jpg
    input.jpg
    585.8 KB · Views: 919

dale_coop

Moderator
Staff member
Hmm... you don't need to duplicate any script.
Your low attack animations (LowFirstL and LowFirstR) to the "Sword" animation type for Down left and Down right... I think.
 

red moon

Member
Ahh, that makes sense. It seems like one of those things I should have thought about harder!
I will try that tonight, thanks Dale!
 

red moon

Member
Sooo close!
As you can see, that worked!
Using the sword and setting the down L and R was key. The left punch works great when crouching, its the right low punch that has the sprite facing the wrong direction.
I imagine fixing that requires some scripting to mirror the sprite based on the direction the Dpad was last pressed?

https://youtu.be/d5gLgdu1fNs
 

Mugi

Member
if you're using the sprite weapon (the code in predraw for drawing it) instead of object weapons, getting the code to properly recocnize the diagonal (DOWN_LEFT / DOWN_RIGHT) directions requires changing the player direction check code.

orignal:
Code:
	LDA Object_movement,x
	AND #%00000111
	TAY ;; now y contains direction, so we can figure out position offset

change it to:

Code:
    LDA Object_movement,x
     AND #%00000110
     TAY                                    ; now y contains direction, so we can figure out position offset

later down there's a piece of code

Code:
	 CPY #RIGHT

change it to

Code:
	 CPY #LEFT

now your weapon draw is able to differentiate diagonal directions.
 

red moon

Member
Thank you both, I will make the changes to the sprite weapon script this evening once i am home.
Getting this to work is a big deal!
 

red moon

Member
I am including my script here for "Handle Sprite Weapon_UsingMonsterHealth" I cannot locate the section of code that contains the CPY #RIGHT code. Maybe this not the correct script to change?

Code:
	GetCurrentActionType player1_object
	CMP #$03 ;; attack state
	BEQ checkSpriteWeapon
	JMP skipSpriteWeaponCheck
checkSpriteWeapon:

	;;;;;;;;;;;;;;;;;;;;;;;;;
	;;here it did equal the melee attack pose.
	LDX player1_object
	LDA Object_movement,x
	AND #%00000111
	TAY ;; direction for offset table index
	LDA Object_x_hi,x
    ;;; offset x for creation
    CLC
    ADC weaponOffsetTableX,y
	STA selfRight
	SEC 
    SBC #$08 ;; width of weapon 
	STA selfLeft
	
	LDA Object_y_hi,x
    ;;; offset x for creation
    CLC
    ADC weaponOffsetTableY,y
	STA selfBottom
	SEC 
    SBC #$08 ;; width of weapon 
	STA selfTop
	;; run through objects.
	
	LDX #$00	
DoMonsterWeaponSpriteLoop:
	LDA Object_flags,x
	AND #%00001000
	BNE +
	JMP ++
+
	JSR GetOtherCollisionBox
	LDA selfRight
	CMP otherLeft
	BCS + ;; no player object collision
	JMP ++
+
	LDA otherRight
	CMP selfLeft
	BCS +
	JMP ++
+
	
	LDA otherBottom
	CMP selfTop
	BCS +
	JMP ++
+
	LDA selfBottom
	CMP otherTop
	BCS +
	JMP ++
+
;; ok, there is a collision with an monster object, from HERE :
;;; what should we do with the monster?
		LDA Object_vulnerability,x
		AND #%00000100 ;; is it weapon immune?
		BEQ notWeaponImmuneSpriteWeapon
		;PlaySound #SFX_MISS
		JMP skipHurtingMonsterAndSoundSpriteWeapon
    notWeaponImmuneSpriteWeapon:
		LDA Object_status,x
		AND #HURT_STATUS_MASK
		BEQ dontskipHurtingMonsterSpriteWeapon
		JMP skipHurtingMonsterSpriteWeapon
    dontskipHurtingMonsterSpriteWeapon:
		LDA Object_status,x
		ORA #%00000001
		STA Object_status,x
		LDA #HURT_TIMER
		STA Object_timer_0,x
		;;; assume idle is in step 0
		ChangeObjectState #$00,#$02
		;;;; unfortunately this recoil is backwards
		LDA Object_status,x
		AND #%00000100
		BNE skipRecoilBecauseOnEdgeSpriteWeapon
		LDA Object_vulnerability,x
		AND #%00001000 
		BNE skipRecoilBecauseOnEdgeSpriteWeapon ;; skip recoil because bit is flipped to ignore recoil

		LDA selfCenterX
		STA recoil_otherX
		LDA selfCenterY
		STA recoil_otherY
		LDA otherCenterX
		STA recoil_selfX
		LDA otherCenterY
		STA recoil_selfY
		JSR DetermineRecoilDirection
    skipRecoilBecauseOnEdgeSpriteWeapon:
		LDA Object_health,x
		SEC
		SBC #$01
		CMP #$01
		BCC isMonsterDeathSpriteWeapon:
		JMP notMonsterDeathSpriteWeapon
		isMonsterDeathSpriteWeapon:

		LDA Object_x_hi,x
		STA temp
		LDA Object_y_hi,x
		STA temp1
		DeactivateCurrentObject
		;CreateObject temp, temp1, #OBJ_MONSTER_DEATH, #$00, currentNametable
		PlaySound #SND_SPLAT
		TXA
		STA tempx
		;AddValue #$08, myScore, #$01, #$00

		;UpdateHud HUD_myScore
		LDX tempx

		JSR HandleDrops
		JSR HandleToggleScrolling
			
		;; check for monter locks begin:
		CountObjects #%00001000, #$00
		LDA monsterCounter
		CLC
		BEQ +
		JMP ++
	+
		.include SCR_KILLED_LAST_MONSTER
		JMP skipHurtingMonsterSpriteWeapon
    notMonsterDeathSpriteWeapon:
		STA Object_health,x
    skipHurtingMonsterSpriteWeapon:
		;PlaySound #SFX_MONSTER_HURT
    skipHurtingMonsterAndSoundSpriteWeapon:
	
++
	INX 
	CPX #TOTAL_MAX_OBJECTS
	BEQ skipSpriteWeaponCheck ;; done with checking against objects 
	JMP DoMonsterWeaponSpriteLoop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
skipSpriteWeaponCheck ;; there is no collision here horizontally.

	;; CHECK FOR Breakable Blocks collisions
	GetCurrentActionType player1_object
	CLC
	CMP #$03	;; player currently attacking?
	BEQ +
	JMP skipSpriteWeaponCheckBreakableTiles
	+
	LDA selfRight
	SEC
	SBC selfLeft
	LSR
	ADC selfLeft
	STA tileX
	LDA selfBottom
	SEC
	SBC selfTop
	LSR
	ADC selfTop
	STA tileY
	JSR GetTileAtPosition
	LDA Object_scroll,x
	AND #%00000001
	BNE +
	LDA collisionTable,y
	JMP ++
	+
	LDA collisionTable2,y
	++
	CLC
	CMP #$0E		;; <-- HERE: the breakable tile type (for this example, we use the type 14)
	BNE skipSpriteWeaponCheckBreakableTiles
	ChangeTileAtCollision #$00, underStomp
	
	PlaySound #SFX_BREAKABLE_BLOCK

skipSpriteWeaponCheckBreakableTiles:
 

Mugi

Member
wrong file.
that's the file that does the weapon hit box. the actual code that DRAWS the weapon is in predraw.asm
 

red moon

Member
Thank you for clarifying Mugi.

I did make the changes to the predraw am in the scrolling platformer main script folder but it appears to have affected all the melee sprites and their facing.

https://youtu.be/m1M_nTMgnqY
 

dale_coop

Moderator
Staff member
So it's not the correct modification for your project...

You could try this:
In you Handle Pre-draw script... put back the line 72-73 like it was before, I mean like that:
Code:
	LDA Object_movement,x
	AND #%00000111


And from the line 94... replace the lines :
Code:
	 CPY #RIGHT
	 BNE directionIsNotRightForDrawingWeaponn
By:
Code:
	 CPY #UP  ;; we will compare with the up, upleft and left directions...
	 BCS directionIsNotRightForDrawingWeapon

If it still doesn't work, could you share your script?
 
Top Bottom