Author Topic: named bricks that actually do stuff  (Read 744 times)

So today I decided to make an RPG. I was going to use vce and create a tree that could be chopped and the player could get the resources, but as soon as I got out my wrench, I thought:

"events are overrated"

What I was thinking of is something that allows a player to place down any brick (not just a tree brick) and name it something specific, like Oak_Tree, and the player could use an axe (in specific) to lower its health to zero, and he/she would receive X amount of wooden logs. No events are used. So for the actual question, I was wondering: how do I make this? (including the axe part)

the general approach would be to package ProjectileData::onCollision, and depending on the projectile datablock, check for different things on the object the projectile hit.

Assuming %col is a brick, you can check if it has a name that contains "tree" or is the same name as a preset list.

You'd also have to write a custom brick health function to calculate the health of a tree and subtract hp from it based on the projectile datablock, and when it reaches 0 call whatever functions you need to remove the tree and give the player the resources they got.

alright, thanks. it works (still doing the health part though)

Might wanna name it Tree_Oak, so all trees are alphabetically sorted together.

Additional, how could I give the player an oak log upon breaking? I've made an addRPGItem function, but how could I actually give the player the item, and when he/she does /inventory, how could it be shown? I've been trying to hours to figure this out.

Edit: The health works, but the players can instantly destroy it when it's planted, but after that the health works. Is there a workaround?

Post your code. If you want to give players oak trees you'll need to store the amount that they have as a variable on them to display later with the command.

Additional, how could I give the player an oak log upon breaking? I've made an addRPGItem function, but how could I actually give the player the item, and when he/she does /inventory, how could it be shown? I've been trying to hours to figure this out.

Edit: The health works, but the players can instantly destroy it when it's planted, but after that the health works. Is there a workaround?
don't just check if health = 0, since any undefined values will be equivalent to 0. Check if it has been damaged before (eg %brick.hasBeenDamaged); if its not, set the health to the starting amount, and then damage the brick.

if your oak tree resource is an actual item carried in their inventory, you can take a look into Event_addItem (found on any rtb archive) and see how it adds the item, given the item datablock/uiname.

edit: shiftkitty's method is better actually - its also how damage is handled for players and is less complicated. basically based on the datablock, it has a certain hp, and instead of subtracting from a brick's hp, add to its damage taken value.
« Last Edit: June 06, 2016, 08:43:34 PM by Conan »

Or do it in reverse.
currdamage >= maxdamage