correct pickup setup help

red moon

Member
Hello, I unsure how to setup my projectile game object so when I pickup the shard object it unlocks the ability to use the projectile. Right now, it is unlocked and I wanted to check and see if using a game object like I have for pickup is problematic.
I am using the projectile source under the player, should the projectile be used instead for the pickup object?
 

Attachments

  • pickup1.jpg
    pickup1.jpg
    529.1 KB · Views: 898
  • pickup2.jpg
    pickup2.jpg
    698.9 KB · Views: 898
  • pickup3.jpg
    pickup3.jpg
    733.4 KB · Views: 898

dale_coop

Moderator
Staff member
hmmm... currenlty only 4 pickup object can have script directly assigned to them (allowing to activate/execute anything you want/need)
The game object #04 (your "GetSword" one), game object #05, game object #06 and game object #07... the scripts assigned to each of them are defined in the "Project Settings > Script Settings" (resp. the PowerUp00, Power01, PowerUp02 and PowerUp03):
2020-01-03-09-36-05-NES-MAKER-4-1-5-Version-0x159-Testscroll-MST.png

So I'd suggest you to use use of those... and assign the script "Basic\ModuleScripts\PowerUpCode\Powerup_UnlockProjectile.asm".
 

red moon

Member
Excellent, that makes sense too...I will give that a shot this evening!
I am only using the health pickup at present, which is something I should consider. Once the projectile pickup is in it will give me 2 left for future use.
 

red moon

Member
Hey Dale,
that screen transition code you showed me really helped. I did go through and setup the projectile unlock as described. However, I found that all my enemies disappeared after the shard pickup. I thought to then set them to day triggered monsters since that seemed to work with setting the music (it changed after pickup) and they are still missing. Also, I seem to start with the projectile unlocked. When I lock the initial weapon (weapon 1) it just prevents me from making a melee attack, not shooting a projectile. Thanks!
Let me know if you want me to zip things up for you to look at.
 

Mugi

Member
just a side note; it's actually really easy to add any number of pickup objects more if that is needed. the code that does the pickup checks is located in bank14.asm inside routines/basic/bankdata
and it simply consists of a check for "if you collide with this object and the object ID is XXXX, .include powerupwhatever.asm"
changing them to use monster objects instead of static objects, changing the pickup object ID's or adding more of them is just about adding a new definition there to check for and include a new assembly file.
 

dale_coop

Moderator
Staff member
red moon said:
Hey Dale,
that screen transition code you showed me really helped. I did go through and setup the projectile unlock as described. However, I found that all my enemies disappeared after the shard pickup. I thought to then set them to day triggered monsters since that seemed to work with setting the music (it changed after pickup) and they are still missing. Also, I seem to start with the projectile unlocked. When I lock the initial weapon (weapon 1) it just prevents me from making a melee attack, not shooting a projectile. Thanks!
Let me know if you want me to zip things up for you to look at.

It's because when you collect a Pickup (for example the get projectile)... its triggered the screen.
Every triggered script have different objects and different placements (also, some special tiles are removed). Just to not have again that pickup object always on the screen, even if you already collected it.

So, first things, you need to define a unique screen-type value to the screen where you have trigger-able object: on that screen where you placed the pickup object, in the screen "Info", set a value for screen-type, a value you haven't set to any other screen (because, don't forget that when a screen is triggered, every screens that have the same screen-type are triggered too).

2020-01-03-22-12-09-D-tails-Ecran.png


And you right, if you had monster objects on that screen... they will be gone too when triggered. If you want to keep them, you will have to assign them to the "Day Triggered Monster" ...

2020-01-03-22-16-31-NES-MAKER-4-1-5-Version-0x159-Testscroll-MST.png


And place them, again, on the "Day - Triggered" version of the screen...

2020-01-03-22-15-33-NES-MAKER-4-1-5-Version-0x159-Testscroll-MST.png



For initially preventing the projectiles... it might be your script that doesn't check it... let me see that...
 

red moon

Member
That's good to know for the future Mugi so I can take advantage over using palettes and thanks for explaining things Dale. I am placing the code here for handle sprite weapon which has the projectile code embedded I believe.

So I understand it correctly, any game object (enemies or NPC's) I just need to assign unique numbers to each screen they are in to get them to go away after interaction? For example, if each talking NPC or sub boss has its own screen variable then they will not return?

That would be great.


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:
 

dale_coop

Moderator
Staff member
Not exactly... every screen can be triggered. It's a state. Normal or Triggered.
Some actions in the game can trigger a screen. Normal screen and triggered screen have different objects assigned and placed. Also triggered screen have some tiles replaced (for example, keys / locked door / monster lock tiles will be replaced by another tile --usually an empty tile--)
The actions that can trigger a screen is: when the NPC text action is trigger the screen... or when the NPC text action is give an item... or when you collect some special pickup objects / key tiles.
(technically it depends gf the scripts you assign to those pickup object or tile collision... in the script if you find the line "TriggerScreen screenType" it means the current screen will be triggered).

And the rule is when a screen is triggered, every screens that share the same screen-type (in the screen "Infos") will be triggered too. It can be useful to, for example, get a key or a special item on one screen... and unlock a path or change the monsters / NPCs on another screen... like a link between those 1 distinct screens)

I think there might be a tutorial video about Trigger screens somewhere.
 

dale_coop

Moderator
Staff member
For your projectile lock/unlock....

Modify your b_create_projectile_latformer.asm script, locate the line:
Code:
canShoot:
And add those 5 lines of code, just after:
Code:
canShoot:
	LDA weaponsUnlocked
	AND #%00000010
	BNE canShootProjUnlocked
	JMP doneShooting
canShootProjUnlocked:

Now your player will be able to shoot projectile only when projectiles are unlocked.
 

red moon

Member
Excellent, that did the trick! Thank you. And the additional explanation on trigger functionality helps as well. In regard with npcs and locks, I will do some experimenting with locks on my next demo for sure!
 
Top Bottom