[4.1] Adding Ammo system (charging weapon) for your projectiles in the Platformer module

Edivad

New member
Hi, I have combined this tutorial with the "Projectiles in the platform module" tutorial and it works perfectly (except for the bullets that still pass through the walls).
By the way, is there a way to stop projectiles and transform them into Ammo items when they collide with a wall?

Thanks!
 

dale_coop

Moderator
Staff member
Edivad said:
Hi, I have combined this tutorial with the "Projectiles in the platform module" tutorial and it works perfectly (except for the bullets that still pass through the walls).

Try this fix:
http://nesmakers.com/viewtopic.php?p=11156#p11156
 
Hey Dale, you helped me with 4.0, but I can't find where to put it on 4.1

I'm trying to reset my total Ammo every time I enter a new screen (specifically, setting it to 0) Any ideas?
 

dale_coop

Moderator
Staff member
Hey Convoy_Avenger :)

You could put yoru code in the HandleLoadScreens.asm (in "Routines\Basic\System" folder)...
Just after the line ";;;;;;;;;;;; SET SCREENS RELATIVE TO THE SCREEN TO BE LOADED" (around line 18), You could add your initialization:
Code:
LDA #$00
STA myAmmo

Notes:
If you have myAmmo displayed on your HUD... AND your element is displayed as a number with 2 digits, it should be:
Code:
LDA #$00
STA myAmmo 
STA myAmmo +1
 
No HUD, so I'll give this a shot, thanks!

Out of curiosity, have you or someone else on the forum set up a system to Melee when you have no Ammo? Using the same button?
 

dale_coop

Moderator
Staff member
Convoy_Avenger said:
No HUD, so I'll give this a shot, thanks!

Out of curiosity, have you or someone else on the forum set up a system to Melee when you have no Ammo? Using the same button?

Yep, look at the previous page... ;)
 
dale_coop said:
Convoy_Avenger said:
No HUD, so I'll give this a shot, thanks!

Out of curiosity, have you or someone else on the forum set up a system to Melee when you have no Ammo? Using the same button?

Yep, look at the previous page... ;)

So I went to go do the Melee object weapon set up you did, then realized I have the Handle Sprite Weapon set up you did. I've modified so many things, now I'm getting lost in them. :S

The ammo thing worked though!

EDIT: I don't actually have my melee set up yet, so maybe I don't need that? I forget what I added it for now. All I'm really using is shooting.
 
dale_coop said:
Oh ok.. If only shooting, you don't need the page 2 suggestions ;)

I would like to add both, I just mean I've added the sprite weapon. I'm not sure how to combine the two, or if I should revert back to normal b to attack script?
 

dale_coop

Moderator
Staff member
It means currently when you are shooting projectiles... your player shows actually his sword too?
I think you could try adding some code to check the Ammo value, in both of your scripts that are assigned to your "b" button (in the projectile one, you can shoot if you have ammo... in the sword one, you can go to the sword attacking state).

For shooting:
Code:
    LDA myAmmo
    BNE +    ;; if NOT equal to 0
    ;;if no Ammo, we're done here.
    RTS
    +
    ;;else we continue:

For attacking:
Code:
    LDA myAmmo
    BEQ +    ;; if equal to 0
    ;;if Ammo, we're done here.
    RTS
    +
    ;;else we continue:
 
Hey Dale, if I wanted to use 2 different types of ammo, that shot the type of the last item I picked up, any ideas how I could make that work? I'm messing with the projectile script now, but doesn't seem to be as easy as just doubling everything up. Will probably need to do a CMP to what ammo I currently have loaded? Then fire and decrease that variable. How I do that in ASM though is totally lost on me... I'll try a few things.

EDIT: Again. I actually DID just double up on everything.. literally everything. Duplicated the ammo script, doubled all the variables and pickups, and just had to change all the Var names and that seems to have done it.
 

going2maine

New member
I've adapted this to the Adventure module, but I'm having one oddity. If I display my ammo in the HUD as a number, everything works fine. But if I try to display it as Var Tiles, something weird happens. Let's say I have the max of both the ammo and the player health set to 5, and both are at their max. If the player gets hurt, dropping its health value to 4, when I move to a different screen the HUD shows 4 for both the health and the ammo. But the variable for the ammo is still 5.
 

dale_coop

Moderator
Staff member
I could be wrong... but, I think every HUD variables displayed as Var Tiles would have this bug (except myHealth)... because there is specifically a code for myhealth hardcoded in the handle hud var tiles script... :p
So yep, I think you are right.
Take a look at this topic: http://nesmakers.com/viewtopic.php?f=60&t=2466
 

going2maine

New member
Nice. That seems to have mostly fixed it. When I change screens it works normally. Now to figure out why when I shoot, it completely zeroes out the tiles, then only redraws them when the charging timer hits.

I feel like I spend more time battling with bugs and hardcoded values with Nesmaker than actual programming...
 

going2maine

New member
I figured it out. I was just calling UpdateHud HUD_myAmmo. I should have been calling:

Code:
	LDA myAmmo	
	STA hudElementTilesToLoad	
	UpdateHud HUD_myAmmo
 

jcramer

New member
Is this compatible with the *simple* platformer module? It's not compiling for me, getting errors.

I added some other code to it, could I be out of space or conflicting with other code, such as the ignore gravity fix?
 

dale_coop

Moderator
Staff member
Oh... it should be compatible, then.

I think you made a mistake in the 2/ of the tutorial. (set a "myAmmo" hud variable name... make sure it's written exactly like that "myAmmo").
 
Top Bottom