4.LatestVersion Projectile Problem

dale_coop

Moderator
Staff member
Dont know what to say or check, looks correct for me.
Are you sure you are the script as shown in the previous messages?
With the action step 05 or you modified it to use 03?
Could you share the script you are currently using?
 

rimoJO

Member
It's set to both 3 and 5.
Code:
    LDA gameHandler
    AND #%00100000  
    BEQ canShoot
    JMP doneShooting
canShoot:
    LDX player1_object
    ;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 3 lines: 
    ;;; check if already shooting (assuming the shoot action step is 05)
    GetCurrentActionType player1_object
    CMP #$03
    BNE notAlreadyShooting
    JMP wasAlreadyShooting 
notAlreadyShooting
    ;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 1 line: 
    ;;; if not already shooting, change it's action step (assuming the shoot action step is 05)
    ChangeObjectState #$05, #$02
    
    ;;; if you want your player stops when he's shooting, comment out the following lines:
    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
    
;; if was already shooting
wasAlreadyShooting:

    LDA Object_movement,x
    AND #%00000111
    STA temp2
    TAY

    LDA Object_x_hi,x
    SEC 
    SBC #$10 ;; width of projectile 
    STA temp
    LDA Object_scroll,x
    SBC #$00
    STA temp3

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

    LDA Object_y_hi,x
    CLC
    ADC projOffsetTableY,y
    sec
    sbc #$10 ;; height of projectile
    STA temp1   
    
    
    CreateObject temp, temp1, #OBJECT_PLAYER_PROJECTILE, #$00, temp3
  
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x
    
    ;PlaySound #SND_SHOOT
doneShooting:
    RTS[\code]
 

dale_coop

Moderator
Staff member
But in the script you modified only one 05... there was two lines about that...
Locate the line:
Code:
  ChangeObjectState #$05, #$02
And replace with
Code:
  ChangeObjectState #$03, #$02
This line change the state of the player to the action step 3 (the last parameter is the speed of your animation)
 

rimoJO

Member
Thank you! Everything seems to be working fine! One more thing, though. Is there any way to limit the amount of projectiles I can make at a time? Because if B is spammed, or (assuming the player is using a turbo feature on a NES Advantage or something) the turbo feature is used, all of the checkable objects, the character, and the projectiles will despawn temporarily and more. Just a small issue.
I'm pretty bad with ASM. I'm good with LUA but not ASM.
 

dale_coop

Moderator
Staff member
Sorry man... the only simple thing you could do, it's add a code to check if a projectile already on the screen, in the shoot script... and if not already on screen, you can continue creating the projectile, if already 1 projectile on screen, you don't create a new projectile.

to do that, in your script, find the line:
Code:
canShoot:
Just after that line, you could add this code:
Code:
canShoot:
    CountObjects #%00000100, #$00   ;; count player weapon on screen
    LDA monsterCounter              ;; the variable used to count is monsterCounter
    CLC
    CMP #$02		;; compare to 2
    BCC +		;; if less than 2 on screen we can create a projectile
    RTS			;; else we quit
    +



Here's the full script:
Code:
    LDA gameHandler
    AND #%00100000  
    BEQ canShoot
    JMP doneShooting
canShoot:
    CountObjects #%00000100, #$00   ;; count player weapon on screen
    LDA monsterCounter              ;; the variable used to count is monsterCounter
    CLC
    CMP #$02		;; compare to 2
    BCC +		;; if less than 2 on screen we can create a projectile
    RTS			;; else we quit
    +
    LDX player1_object
    ;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 3 lines: 
    ;;; check if already shooting (assuming the shoot action step is 05)
    GetCurrentActionType player1_object
    CMP #$03
    BNE notAlreadyShooting
    JMP wasAlreadyShooting 
notAlreadyShooting
    ;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 1 line: 
    ;;; if not already shooting, change it's action step (assuming the shoot action step is 05)
    ChangeObjectState #$03, #$02
    
    ;;; if you want your player stops when he's shooting, comment out the following lines:
    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
    
;; if was already shooting
wasAlreadyShooting:

    LDA Object_movement,x
    AND #%00000111
    STA temp2
    TAY

    LDA Object_x_hi,x
    SEC 
    SBC #$10 ;; width of projectile 
    STA temp
    LDA Object_scroll,x
    SBC #$00
    STA temp3

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

    LDA Object_y_hi,x
    CLC
    ADC projOffsetTableY,y
    sec
    sbc #$10 ;; height of projectile
    STA temp1   
    
    
    CreateObject temp, temp1, #OBJECT_PLAYER_PROJECTILE, #$00, temp3
  
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x
    
    ;PlaySound #SND_SHOOT
doneShooting:
    RTS[\code]
 

rimoJO

Member
...k.

Also, it's not related to the projectile, but in my game, there's a house. In the house, there are two beds. One bed is fine. It's checkable, and just good. But there's another bed in another part of the house that just keeps respawning parts of itself and breaks the game. The bed is a monster, set to NPC. So you can't have more than one NPC in a game?
 

rimoJO

Member
There's a problem that I've been trying to figure out for a while now, and nothing's worked. When I input the button combination that creates the projectile in the game, it doesn't. It plays the animation, but nothing else. Honestly, I have no idea what to say, or screenshot, or anything for information... so yeah that

EDIT: Oh and I also tried screen extend but it didn't work
 

rimoJO

Member
and about the comment above, some information:
weapon 2 and all of the others are unlocked
the projectile is set to player weapon
i am using the real projectile in the platformer module script
press b doesn't work
hold down+b doesn't work
nothing works
plz help
 

dale_coop

Moderator
Staff member
The script is assigned to your b press button ?
Could you share a screenshot of the « Input Editor » window?
And share the shooting script?
 

rimoJO

Member
Code:
    LDA gameHandler
    AND #%00100000  
    BEQ canShoot
    JMP doneShooting
canShoot:
    CountObjects #%00000100, #$00   ;; count player weapon on screen
    LDA monsterCounter              ;; the variable used to count is monsterCounter
    CLC
    CMP #$02        ;; compare to 2
    BCC +       ;; if less than 2 on screen we can create a projectile
    RTS         ;; else we quit
    +
    LDX player1_object
    ;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 3 lines: 
    ;;; check if already shooting (assuming the shoot action step is 05)
    GetCurrentActionType player1_object
    CMP #$03
    BNE notAlreadyShooting
    JMP wasAlreadyShooting 
notAlreadyShooting
    ;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 1 line: 
    ;;; if not already shooting, change it's action step (assuming the shoot action step is 05)
    ChangeObjectState #$03, #$02
    
    ;;; if you want your player stops when he's shooting, comment out the following lines:
    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
    
;; if was already shooting
wasAlreadyShooting:

    LDA Object_movement,x
    AND #%00000111
    STA temp2
    TAY

    LDA Object_x_hi,x
    SEC 
    SBC #$10 ;; width of projectile 
    STA temp
    SBC #$00
    STA temp3

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

    LDA Object_y_hi,x
    CLC
    ADC projOffsetTableY,y
    sec
    sbc #$10 ;; height of projectile
    STA temp1   
    
    
    CreateObject temp, temp1, #OBJECT_PLAYER_PROJECTILE, #$00, temp3
  
    ;;;; x is now the newly created object's x.
    LDA Object_movement,x
    ORA temp2
    STA Object_movement,x
    LDY temp2
    LDA directionTable,y
    ORA Object_movement,x
    STA Object_movement,x
    
    ;PlaySound #SND_SHOOT
doneShooting:
    RTS
 

Attachments

  • Input Editor (if you're reading this, plz check out shadows caverns wip page).PNG
    Input Editor (if you're reading this, plz check out shadows caverns wip page).PNG
    22.4 KB · Views: 931

dale_coop

Moderator
Staff member
Your projectile object is correctly set?
Bounding box, action step 0 to ignore gravity and a speed and acceleration ,
Which object are you using?
Your “OBJECT_PLAYER_PROJECTILE” user constant is set accordingly?
 

dale_coop

Moderator
Staff member
rimoJO said:
Changed player projectile constant to 3 (projectile source). nothing changed.

And your "projectile source" object is set? graphics, "player weapon" speed and acceleration, ignore gravity for the action step 0, bounding box... ?
Don't know what to say... it should work.

If you want, I could check your project, could you share your nesmaker folder zipped (more precisely I 'd need the project MST file, the GraphicAssets and GameEngineData folders).
 
Top Bottom