Destructible game object question

red moon

Member
I had a number of general questions, so I will post them individually over the next couple of days to not overwhelm the thread


It is possible to set a game object that is destructible to not damage the player?

What I have at present functions. There are weeds, roots and moss that can be destroyed to allow the player to pass by or uncover a hidden object. They damage the player at present, which feels a bit odd. I tried different settings and as NPC you simple walk behind them which is not as satisfying. I am wondering, even without damage could you walk through them even though they have bounding volumes? I seem to be able to into enemies crossing into their bounding volume which then adds a bit of knock back. And that would be fine if your bounding volume entered their bounding volume and then you were knocked back but not damaged.

Thanks for taking the time to read this. I can put up screens if need be, but did not seem like a case that it would!
 

dale_coop

Moderator
Staff member
Currently, objects can't be destrutible and harmless at the same time.
In NESmaker you have breakable tile type. That are solid tiles, that can be broken (by the projectile I guess).

So, with a few modifications you could either have more versatile breakable tiles (be breakable my any weapon) or have specific code for some monsters to be harmless...
Or another possiblity would be to implement the "Strength" of an object... the damage will not be "1" anymore but would depend of the "Strength" value of the other objects in collision (so you could set all your monsters to "1" or more... and have monsters with "0" strength that would make no damage to the player). It requires some code.
 

red moon

Member
Thanks for the quick reply. I think the breakable tile would be preferred in this case. I will look through the ask for help to see if I can located breakable tile construction. I looked through all the tutorial videos and did not find any mention of it.
 

dale_coop

Moderator
Staff member
The BreakableBlock.asm script should be in the tiles > scrollingPlatformer sub-folder. (you could assign it to an unused "Tile Collision ??" element in "Project Settings > Script Settings").
 

red moon

Member
Thanks Dale, I did locate that script and assign it to tile 14 and placed it in a test area but could not get it to break with melee or projectiles. I can post some screens, I added the script and create a new tile setting it to 14 and placed it. I must be missing an additional step?
 

dale_coop

Moderator
Staff member
About the Breakable script... you could modify it and replace the line:
Code:
	CMP #$03 ;; is a projectile?  Change this is you want to use a different object #.
by:
Code:
	CMP #OBJECT_PLAYER_PROJECTILE ;; is a projectile?  Change this is you want to use a different object #.
 

dale_coop

Moderator
Staff member
If you want to use ALSO for the melee weapon, tell me, because the modification would be different ;)
 

red moon

Member
Great, I will modify the code and take some screens once I am home and post them. And I think it would be great to have it work for a melee attack!
 

red moon

Member
Dale, I took some screens to share showing the changes. Let me know if you need anymore to see what is going on!
 

Attachments

  • break1.jpg
    break1.jpg
    1 MB · Views: 1,566
  • break2.jpg
    break2.jpg
    1.1 MB · Views: 1,567
  • break3.jpg
    break3.jpg
    1.3 MB · Views: 1,567
  • break4.jpg
    break4.jpg
    560.6 KB · Views: 1,567

dale_coop

Moderator
Staff member
The script I shared previously should work for your Projectile object.

Now, for your sprite based Melee weapon, you'll have to modify the script "HandleSpriteWeapon_UsingMonsterHealth.asm" that is assigned the "Use Sprite Based Weapon" element in your "Project Settings > Script Settings"... and the end, just after the last line of that script, add this block of code:

Code:
	;; 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:
 

red moon

Member
That did it! Both scripts worked and enabled me to break tiles, thank you!

One thing, I wanted to ask though. Is there a special type of tile that will not respawn? I wanted to place blocks that could be broken to walk into other screens but once you enter the new screen you cannot return since the break blocks on the other side have been respawned.
 

Attachments

  • works.jpg
    works.jpg
    475.2 KB · Views: 1,205
  • stuck.jpg
    stuck.jpg
    462.6 KB · Views: 1,205

Bucket Mouse

Active member
The first time the blocks are broken, you put a flag up (a user variable) and then whenever that screen reloads, it checks for the flag -- and if it's up, it draws different tiles in that one spot.
 

dale_coop

Moderator
Staff member
You can't do that Bucket Mouse, because you'd need one flag per screen.
A better solution, would be to make the breakable tiles triggerable, when you break it, the screen is triggered... and when you entered on a triggered screen, those tiles are removed (replaced by another "empty" tiles), like the key tiles, the monster lock tiles, the door tiles,...
 

red moon

Member
Ahh, I see. So I should create a 2nd breakable block that can be used at the edge of screens. Thanks for the help!
Are there setting in the editor or would that trigger be done with code added to the breakableblock script?
 

red moon

Member
I am understand it after giving it some thought, previously entered screens would have tiles that change state to a black title by default as an example if that swap state has been triggered.
 

red moon

Member
Thank you, I am experimenting a bit as I go...I am happy to hear that you like the look. At present, I am working on a burning town and underground castle set and should have something to show soon!
 
Top Bottom