SetDamage method for PlayerHitVegetationEvent

  • Hey


    is there a specific reason why PlayerHitVegetationEvent doesn't have the SetDamage method? All the other hit events provide it for some reason (Check screenshot below). It would be nice to also have it for that event.


    HdAZ8pr.png


    Just in case if someone's asking for a good use case:

    I am currently working on a level system which supposed to give the player more strength (= damage, speed etc.) depending on their level. As you might guessed I need an method like that to alter the damage for vegatations as well.

  • Hi, I think that for other events you can use getHealth and setHealth methods in player, but I'm not sure if they will show you damage animation or not

    Thanks for the fast reply, but I think there's a misunderstanding. What I'm looking for is a method which allows you to manipulate the incoming damage of vegatation entities (such as trees, plants, etc.).

    Basically I wanna multiply the damage by a given factor (which depends on the level) to simulate the strength as I mentioned above.

  • manipulate the incoming damage of vegatation entities

    I think that there is no such damage for plants, most likely that they are not entities and have a separate object type. So you since you can't control thing that doesn't exist you will need to implement your own damage system for vegetation with these methods

  • I think that there is no such damage for plants, most likely that they are not entities and have a separate object type. So you since you can't control thing that doesn't exist you will need to implement your own damage system for vegetation with these methods

    Check the doc site, there's a GetDamage method for plants (check screenshow below). And also I've tested it locally, it tracks the damage as expected, but unfortunately I can't modify the value as I wanted :$

    nlXyCDE.png


    // Edit:

    with plants I meant stuff like bushes which of course have a hitbox.. (sorry for the misunderstanding)

  • Check the doc site, there's a GetDamage method for plants (check screenshow below). And also I've tested it locally, it tracks the damage as expected, but unfortunately I can't modify the value as I wanted :$

    Wait, do you mean situation when player get damage from plant or when plant get damage from player (like tree cutting)? Event in the docs is about the second one

  • Wait, do you mean situation when player get damage from plant or when plant get damage from player (like tree cutting)? Event in the docs is about the second one

    The second one of course when plant get damage from player :D (i.e. to increase the speed of cutting a tree) I mean it wouldn't make much sense for a level system to handle player damage from plant.

  • when plant get damage from player

    In that case it should be simple - you can cancel the event and then damage plant manually, for example you can use getDamage and multiply it on level (or any other system that you will implement). Event itself don't provide you the plant object, but it provides you getGlobalID method, so you can get this object from the world with getObject method and apply custom damage to it with setStrength. That should work fine (probably)

  • In that case it should be simple - you can cancel the event and then damage plant manually, for example you can use getDamage and multiply it on level (or any other system that you will implement). Event itself don't provide you the plant object, but it provides you getGlobalID method, so you can get this object from the world with getObject method and apply custom damage to it with setStrength. That should work fine (probably)

    I will give it a try, thanks!

  • In that case it should be simple - you can cancel the event and then damage plant manually, for example you can use getDamage and multiply it on level (or any other system that you will implement). Event itself don't provide you the plant object, but it provides you getGlobalID method, so you can get this object from the world with getObject method and apply custom damage to it with setStrength. That should work fine (probably)

    I gave it a try so others don't have to do too. Using following Code when the event was a PlayerHitVegetationEvent:

    Code
    ObjectElement gameobject = net.risingworld.api.World.getObject(event.getGlobalID(), event.getChunkPositionX(), event.getChunkPositionY(), event.getChunkPositionZ());


    sadly "gameobject" is null in this case so it doesn't really work that way ...

    actually I did do that not ro modify the damage (which is already possible by now) but to get the current strength of an object which is not available in the event.


    Update: forgot to mention i did hit a tree to verify that code ;-)


    Update2:

    LOL ... adding last comment made me thing about it once again ... as ai was hitting a tree obviously the right thing to do is

    Code
    Plant gameobject = net.risingworld.api.World.getPlant(event.getGlobalID(), event.getChunkPositionX(), event.getChunkPositionY(), event.getChunkPositionZ());

    if you do it that way it's gonna work.

    btw due to how rising world works some things like "boulders" and "rocks" are most likely considered as plant too.

  • It's indeed necessary to get a Plant when working with vegetation/plants/trees etc (in conjunction with the World.getPlant() method) ;) ObjectElement only represents furniture, fixtures, workbenches, doors, lamps etc, basically any kind of furniture and fixtures that can be placed by the player.


    But probably it would be also a good idea if we add a getPlant() method directly to the vegetation events (and getObject()/getConstructionElement() to the object/construction events accordingly). We will do this with the next update^^


    However, the PlayerHitVegetationEvent also got a setDamage() method in the meantime, so if you just want to change the amount of damage the player inflicts to the plant, you can simply use the setDamage() method ^^


    SetDamage method would be helpfull in PlayerHitTerrainEvent too ;-)

    Yes, definitely, we will add this with the next update ;)

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!