Evolve on damage instead of time?

simple question, tricky answer unless im lucky…
Q: is it possible to trigger evolution (like crops etc.) on damage instead of time?

why would you want that wouter/thahat? well, them i could make trees have felled form, so the first 2-3 chops would drop them, and the next few would havest the wood. to remove the minecraft-punching-trees feel.
@max99x maybe? possibly @BrunoSupremo or even @RepeatPan (you guys tend to know the weard stuff i ask :wink: )
afbeelding

Not with the normal growing component, but it’s doable with an own one I guess. Not sure what you need to be considered a crop though; but even then you could make a fake-crop component with just one stage and handle the “real” crop details in your own component.

In any case, it does kinda not fit into the SH gameplay (which is grow sapling, then plant it somewhere, watch it mature, then chop it down). I don’t feel like that’s Minecraft-ish, but actually quite real.

sorry i was being a bit too vague on the crop part i guess.
i just ment :

 "stonehearth:evolve": {},

"stonehearth:evolve_data": {
         "next_stage": "nordlingmod:charcoal_mound_phase_2",
         "evolve_time": "1h+1h"
      }

currently you can give anythign the evolve stuff. ive got a work-in-progress charcoal mound going with it (and it works) and only the final stage is harvestable.

what i was thinking is isntead of evolve_time something like evolve_damage

now i think about it it would have to be a seperatestyle of evolve like you say, because trees would need both versions, with different .jsons they would point at to evolve into.
(evolve in time into a bigger tree, but evolve to the correct chopped over version on enough damage)
and this will probably involve lua… which im shit at XD

evil well i found the evolve component… but i fear im better off using another component as an example because 90% of this thing is about time. and i feel damage ought to be…simpler? anyone know where the kocked unconcius/death stuff is? might be able to verse engineer that

Just keep in mind that, unless that has changed, trees don’t really have HP. Swinging the axe at them doesn’t hurt them per se, it’s just an effect tied to a component spitting out resources.

So your premise might be wrong if you want to emulate that, since HP itself is nowhere in that equation. If you truly want it to be “attacked”, then it would need to be an enemy which is… quite overkill.

…crap i had not concidered that. its ofcoarse a resource node and that “damage” is not actual damage.

so taking a step back, it would need to be a changed resource_node code.
where after enough “damage” ticks the model (could) change if its specified in the entities .json.
preferably with a tree-falling-down-sound effect.

aaaand this is the point where i know i cant do this, because that is, well not to put a fine point on it, you-tier code, RepeatPan :’) (mixing new code into existing trees: no problem, models, no problem, sound i could probably scrounge up and make…so the legwork i can do. but the modified resource node: nope. :confused: *

*or at least i would not know where to start beyond taking the normal resource node code, and searching for a lua that changes a models appearance… which nothing does i think?

Well, looking at the evolve component, it seems like it is more or less doing what you want: Creating a new entity and destroying the old one (evolve.lua; :evolve()). So you should be able to use the evolve component.

However, that’s just after quickly skimming over the code. Have a new entity that has your model, and a resource node, and have your proto-entity evolve into that.

yeah i know how the evolve one works, but it works by time. and indeed it removes an entitie and makes a new one. my first idea would indeed be something like tha,t but if you do it that way it doesnt stay marked for harvest, which would add more player-required interaction (like that one mod that adds tree stumps) i could just reverse engiener that one for this effect.

the best case scenarion would be that, but keeping them marked for harvest, or just changing the model after X chops.

If I wanted to make a mod like this I would make a copy of resource_node_component.lua, and edit it so that at the end of spawn_resource, after radiant.entities.kill_entity(self._entity), it spawns a new entity and marks it for harvest (see the request_harvest method a few lines down).

5 Likes

That sounds like something I might just possible be able to do, thanks max!

1 Like

Max always arrives to save the day :smiley:

I’ll be lurking since similar uses might interest me :wink:

2 Likes

right, so after the second line, before end

   if self._sv.durability <= 0 then
      radiant.entities.kill_entity(self._entity)
   end

we will need some code that spawns a new entitiy and marks it for harvest.

this i dont see though :confused:

we will need some code that spawns a new entitiy and marks it for harvest.

Yes. You can probably borrow code from the evolve component.

this i dont see though :confused:

1 Like

well i -think- this is the “set what is the next step, and spawn it” code…

 local evolved_form_uri = self._evolve_data.next_stage
   --Create the evolved entity and put it on the ground
   local evolved_form = radiant.entities.create_entity(evolved_form_uri, { owner = self._entity})

which points at

 "stonehearth:evolve_data": {
         "next_stage": "nordlingmod:charcoal_mound_phase_2",
         "evolve_time": "1h+1h"
      }

in the Json.
but since we arent using stonehearth:evolve_data"
but our new nordlingmod:resource_node_advanced

something would have to change about

 local evolved_form_uri = self._evolve_data.next_stage

…i think. im just thinking out loud here because i have no clue what im doing to be fair :confused: