Questions about weapons

Havok

New member
I have some general questions regarding weapon handling in NES Maker.

First, given the 1-hit-kill nature of the sprite-based melee weapon, I don't want to use it in my game. I understand that both melee and projectile weapons can be set using game objects, but are we limited to just 2 game objects for them? I wanted to create multiple weapons for use throughout the game. Is it possible to spawn different types of projectiles, for example, depending on whether you've gotten a new upgrade or powerup?

Second, is it possible to toggle weapon types? For example, let's say I want to have a certain type of projectile usable on one screen, but want to use a different type for another screen.

Third, is there any way to modify the damage values of weapons? As it stands, each hit reduces a monster's health by 1. Is it possible to, say, have a weapon that reduces their health by 2, 3, or any other amount other than 1?

Sorry to ask so many questions, but I've been spending hours searching, testing, and trying to crack this nut on my own, but I've hit a wall.
 

Havok

New member
Just to add, if these questions are too complicated to resolve, simply being able to change the state of the projectile object at will might be sufficient. I can change the state of the player object no problem, and I'm wondering if I can use the same principle to change the state of the projectile.

The issue is that unlike the player, I don't know how to refer to the projectile in the script. Is there something like the equivalent of player1_object to refer to the projectile (or any other game object for that matter), or is it more complicated than that?
 

dale_coop

Moderator
Staff member
In the create projectile script, there is a createobject line with the object is used (#OBJ_player_PROJECTILE » or somethig like that... the value is defined in the project settings > user constants).
The next parameter is te action step used for this object as projectile (#$00).
 

Havok

New member
Thanks, that does help, but now my problem is that the projectile's state doesn't remain at the changed state. For example, if I set a tile to change the projectile's state, the projectile will appear as the new state as long as the player remains on the tile, but reverts to the original state as soon as the player leaves the tile. I also tried to change it via a powerup (as I had successfully done previously with the player object), but it had no effect on the state of the projectile. I tried commenting out ChangeObjectState in HandleUpdateObjects, but it didn't work either. How might I change the state so that the projectile remains at the new state until I decide otherwise?

To make it clearer what I'm trying to achieve, I want to have the player's projectile appear as different sprites depending on the screen. So for example, I might want a player to use a fireball on level 1, but I want them to use a throwing star on level 2, then go back to using a fireball on level 3, and so on.
 

Havok

New member
I wanted to add that what I'm really looking for most of all is a way to toggle weapon availability in the adventure module. I figured out how to create new weapons via the createObject_simple.asm script, but the big issue I'm running into now is that weapon unlocks seem to be one-way. Is it possible to re-lock/disable/toggle/remove (however you want to describe it) weapons? I can find where the weaponsUnlocked variable appears, but I'm not certain how to reverse it.

Again, to make my goal clear, I want to be able to control which weapons are available to the player based on the screen they're on. For example, the player might have access to a sword and fireball in level 1, but on level 2, I want to disable their sword and possibly replace it with a different weapon, but I want to re-enable the sword on level 3, etc.
 

dale_coop

Moderator
Staff member
You could search all the occurrences of "weaponsUnlocked" in the scripts that are in the "Routines\Basic" folder to know where it is used?
But basically if you want to use the weaponsUnlocked variable in your scripts :


Code:
;; give the Weapon 1:
LDA weaponsUnlocked
ORA #%00000001
STA weaponsUnlocked

;; remove the Weapon 1:
LDA weaponsUnlocked
AND #%11111110
STA weaponsUnlocked

;; give the Weapon 2:
LDA weaponsUnlocked
ORA #%00000010
STA weaponsUnlocked

;; remove the Weapon 2:
LDA weaponsUnlocked
AND #%11111101
STA weaponsUnlocked

;; give the Weapon 3:
LDA weaponsUnlocked
ORA #%00000100
STA weaponsUnlocked

;; remove the Weapon 3:
LDA weaponsUnlocked
AND #%11111011
STA weaponsUnlocked

;; give the Weapon 4:
LDA weaponsUnlocked
ORA #%00001000
STA weaponsUnlocked

;; remove the Weapon 4:
LDA weaponsUnlocked
AND #%11110111
STA weaponsUnlocked

;; etc

And to test if the player has a weapon :

Code:
;; test if the player has the Weapon 1:
LDA weaponsUnlocked
AND #%00000001
BEQ playerDoesNotHaveWeapon1
;; else he has unlocked the Weapon1


;; test if the player has the Weapon 2:
LDA weaponsUnlocked
AND #%00000010
BEQ playerDoesNotHaveWeapon2
;; else he has unlocked the Weapon2

;;ETC...
 

dale_coop

Moderator
Staff member
To change the action step (the animation) of your projectile, just change the parameter of the CreateObject on the create projectile script:
Code:
  CreateObject temp, temp1, #OBJECT_PLAYER_PROJECTILE, #$00, temp3
#$00 is the action step 0...

So, for example, you could use another one on your screens (you could use the "temp2" variable to store temporary the value before creating the object):
Code:
;; if my screen if the 01
LDA currentScreen
CMP #$01
BNE +
	LDA #$00
	STA temp2
	JMP continueCreatingTheProjectileObject
+
;; if my screen if the 02
LDA currentScreen
CMP #$02
BNE +
	LDA #$01
	STA temp2
	JMP continueCreatingTheProjectileObject
+
;; if my screen if the 03
LDA currentScreen
CMP #$03
BNE +
	LDA #$02
	STA temp2
	JMP continueCreatingTheProjectileObject
+
;; etc :
continueCreatingTheProjectileObject:
	CreateObject temp, temp1, #OBJECT_PLAYER_PROJECTILE, temp2, temp3
 

Havok

New member
Thank you again, Dale! You may have saved my project. I needed those "AND" values that you provided to remove (or "re-lock") the weapons. Just one note for anyone who might read this and have a similar issue, I needed to change the second "LDA" to "STA" to get the code to work. So instead of

Code:
;; give the Weapon 1:
LDA weaponsUnlocked
ORA #%00000001
LDA weaponsUnlocked

;; remove the Weapon 1:
LDA weaponsUnlocked
AND #%11111110
LDA weaponsUnlocked

it should be

Code:
;; give the Weapon 1:
LDA weaponsUnlocked
ORA #%00000001
STA weaponsUnlocked

;; remove the Weapon 1:
LDA weaponsUnlocked
AND #%11111110
STA weaponsUnlocked

and so on.

The resulting script can be inserted into a tile, powerup, etc. to effectively toggle the weapon unlocks, allowing control over what weapons the player has available and when.
 

dale_coop

Moderator
Staff member
Lol, yep :p sorry, you right, of course it's STA ;)
I wrote it quicly in the train with my iPhone :p... copy/pasted lines... forgot to edit.

Note: I will edit my previous post, for the future members that would come here for the same things... don't want them to copy my typos :p thanks Havoc ;)
 
Top Bottom