Create Projectile doesn't work in platform module?

Imagaryboy

New member
I'm trying to add the ability to shoot in my platform game, but the "create projectile"-script from the adventure module doesn't work in the platform module.
I found the "shoot weapon"-script in the platform module, but that one just gives me those errors:

Routines\UserScripts\PlatformGame_Base\InputScripts\shootWeapon.asm(28): Unknown label.
Routines\UserScripts\PlatformGame_Base\InputScripts\shootWeapon.asm(37): Unknown label.

Not sure what to do now...
 

WolfMerrik

New member
The compiler errors want us to look at lines 28, and 37 of shootWeapon.asm (the script in question)
It seems there is a problem with the label preventShooting as not being defined.

So if we define it, and set it so that our code knows when we can shoot or not, it should work
 

WolfMerrik

New member
Try adding this line to Routines\Variables\SystemVariables.asm

Code:
preventShooting .dsb 1

It should at least get you to compile
 

Imagaryboy

New member
Yeah, it compiles now but when I press the assigned shoot button, it only creates the melee game object once without any movement, even though I set movement speed in object details...
 

WolfMerrik

New member
Imagaryboy said:
Yeah, it compiles now but when I press the assigned shoot button, it only creates the melee game object once without any movement, even though I set movement speed in object details...

I believe that the object it is creating is from this line
Code:
CreateObject temp,temp1,#$01, #$00

Have you tried changing this to be to the object you want to create? I believe the "Projectile Object" (in the default game objects) would be #$03,
Although it should not really matter which object you use, as long as the object itself if setup right.
 

Imagaryboy

New member
That's what I was thinking as well. But I guess the projectile movement has to be defined within the "ShootWeapon"-script
 

WolfMerrik

New member
One thing that might make it easier for testing,
add this to the beginning of the shootWeapon.asm script

Code:
LDA #$00
STA preventShooting

This will make it so you can shoot regardless basically, as it sets the preventShooting to false,
you will want to of course change what prevents you from shooting elsewhere,
but it will let you continuously shoot, and make changes to the creation of the projectile.
 

Imagaryboy

New member
Oh thanks, that worked!
But I am not able to change the projectile offset. The projectile always spawns at the top right tile of the player object and too far away from the player.
 

WolfMerrik

New member
I believe that script does not define any offset, It was likely unfinished, and why it didn't make it into the tutorial.
Take a look at the adventure games a_create_projectile.asm, that used the offsets and I believe that even had them commented where it does in the script
 

Imagaryboy

New member
WolfMerrik said:
I believe that script does not define any offset, It was likely unfinished, and why it didn't make it into the tutorial.
Take a look at the adventure games a_create_projectile.asm, that used the offsets and I believe that even had them commented where it does in the script

Do you have any idea how we can make the projectile script from the adventure module work in the platform module? I want to set up an Item that gives the player the ability to shoot, and this mechanic is already built into the script from the adventure module.
 

WolfMerrik

New member
Imagaryboy said:
Do you have any idea how we can make the projectile script from the adventure module work in the platform module? I want to set up an Item that gives the player the ability to shoot, and this mechanic is already built into the script from the adventure module.

The trick to that would be making an item pickup that unlocks the weapon,
Then we can read the flag:

This would be
Code:
LDA weaponsUnlocked 	; Load what weapons are unlocked
AND #%00000001 		; Assuming the "gun" is weapon 1, or change this to whatever
BNE shoot: 		; If we can shoot, we would go to the logic that shoots 
JMP noShoot		; If not, we go to the end logic
shoot:
			; Shooting code here;
noShoot: 
			; IF we have something that would still trigger, like a different (empty clip?) sfx, etc
			; it would go here.
RTS 			; script over

This should create a script, or a basis of one based on item flags being unlocked
 

WolfMerrik

New member
Imagaryboy said:
You truly are an ASM hero! Thanks a lot!

It's weirdly not that hard to understand.... it was not until about 2-3 days ago I started even attempting writing it.
It looks REALLY GODDAMN CONFUSING AND HARD... but it's all linear, and when I encounter an instruction I don't know, Google helps! (although sometimes searching for a 3 letter term brings up a LOT of acronyms for businesses)

I need to make a cheat sheet for the instructions and what they do, print them out, etc.

And thank you! haha :D

Also, let me know if that works, I did not test it, just was trying to write an ASM equivalent to an if/else statement for the weapon flag, so hopefully, it does work.
 

Imagaryboy

New member
Your script works perfectly fine, Thanks again for sharing!

One more thing xD :

I wanted to let the player shoot by pressing UP and B.
But in the input editor, if I assign the projectile script to Up and B, the input editor reads it as "if UP OR B is pressed, call the projectile script". So if I press either UP or B, the player shoots without waiting for both button presses:/
 

dale_coop

Moderator
Staff member
Imagaryboy said:
I wanted to let the player shoot by pressing UP and B.
But in the input editor, if I assign the projectile script to Up and B, the input editor reads it as "if UP OR B is pressed, call the projectile script". So if I press either UP or B, the player shoots without waiting for both button presses:/

You could add a check for the gamepad pressing Up button in the WorlfMerrik script, something like this:
Code:
LDA weaponsUnlocked 	; Load what weapons are unlocked
AND #%00000001 		; Assuming the "gun" is weapon 1, or change this to whatever
BNE shoot  		; If we can shoot, we would go to the logic that shoots 
JMP noShoot		; If not, we go to the end logic
shoot:
	LDA gamepad
	AND #%11110000
	CMP #%00010000 ;; check if UP is pressed
	BEQ canShoot
	JMP noShoot
canShoot:
			; Shooting code here;
noShoot: 
			; IF we have something that would still trigger, like a different (empty clip?) sfx, etc
			; it would go here.
RTS 			; script over

And assign this script just on your "B" button.
 

WolfMerrik

New member
Oh, I like that, you could easily make an alternate shooting method from that, (like a sub weapon script)

Something like:

Code:
LDA weaponsUnlocked 	; Load what weapons are unlocked
AND #%00000001 		; Assuming the "gun" is weapon 1, or change this to whatever
BNE canShoot		; If we can shoot, we would go to the logic that shoots 
JMP shootingDone	; If not, we go to the end logic

canShoot:
	LDA gamepad
	AND #%11110000
	CMP #%00010000 		; Check if UP is pressed
	BEQ canShootSubWeapon
	JMP canShootNormal
	
canShootNormal:
				; Shooting NORMAL WEAPON code here;
	JMP shootingDone	; After, get out of here, to avoid the other code
	
canShootSubWeapon:
				; Shooting SUB WEAPON code here;
				; We could even make a check which SUB WEAPON we have, and jump to that corresponding logic
	JMP shootingDone	; After, get out of here, in case we put subweapon code below.	
	
shootingDone: 
			; IF we have something that would still trigger, like a different (empty clip?) sfx, etc
			; it would go here.
RTS 			; script over
 
Top Bottom