MovingBlocks / Terasology

Terasology - open source voxel world
http://terasology.org
Apache License 2.0
3.69k stars 1.34k forks source link

Add a simple command that makes the player immune to damage #2837

Closed Cervator closed 4 years ago

Cervator commented 7 years ago

More or less the traditional "god mode" - unless that term has become too loaded by now. What's it called in some other recent games? Maybe it should just be damageImmunity instead (keep reading, more further down)

We already have "flight" and "ghost" (flight + noclip) so this command should just focus on cancelling all damage affecting the player.

See HealthCommands where softLanding heavily restricts fall damage from a player (and is probably where the new command should go) or maybe the physical resist system in the AlterationEffects/Potions modules.

Alternatively for a nicer approach support including a damage type to make the player specifically immune to, rather than only support global damage immunity. That (along with a command to inflict typed damage - see #2809) would go a long way to make it easier to distinguish between and test out different kinds of and sources for damage.

So we could have a simple command for damage immunity against everything, with a variant taking a parameter for the damage type. Same for doing damage.

Interestingly enough the hjump command over in MovementDebugCommands once upon a time did include damage immunity from falling. It wasn't taken off with restoreSpeed so #1247 fixed that - and made me realize that isn't there anymore (fix was from late 2014). Huh!

So if interested in digging deeper that might be something additional to look at. We used to have damage immunity applied in some cases, and more damage dealing in others, like smashing into walls with hspeed on could actually kill you from "horizontal fall damage" - why'd we ever take that off .... :D

krishnasism commented 7 years ago

Hi! I have been able to implement the feature, but I am unable to do a pull request due to some network issues. Could you suggest an alternate way via which I can show you the feature? Thanks.

krishnasism commented 7 years ago

2845 Added damageStop Command

Toggles between damage inflicted to player by fall.

portokaliu commented 7 years ago

@krishnasism I don't thing that putting in something this specific would be wise. Why not just make it a general player attribute? This way any mod that wants to fiddle with the setting would just have that to hook on to. (like say, a feather fall potion - which btw, you might wanna check if it exists in the potions mod)

While doing so, if you could consider adding damage types (like say: weapon, gravity, burning, drowning, poison etc) that would be nice to have (again, might be covered in another mod tho :P )

Weilin1992 commented 7 years ago

@portokaliu what do you think of my implementation? I'm going to make DisableHealthComponent as a subclass of HealthComponent,

portokaliu commented 7 years ago

@Weilin1992 I did read your version at about the same time. I have my doubts on the whole "new component" idea, since adding more components wouldn't be the best idea imo.

It does prevent adding a check for a bool though for every health related event, but that's about it.

I do believe that my code is a bit old, because I see health related commands in the authority system, which i do not seem to have. Will check when I get home (where the code is up to date) and get back to this thread then

Weilin1992 commented 7 years ago

@portokaliu there is another problem for adding an attribute. It will make health component larger, I'm not sure how many entities in a Scene and it seems every entity has a health component, if we add more attribute to health component, it will make memory larger

OvermindDL1 commented 7 years ago

I'm still thinking a component to hold other components that are specifically disabled, that way they are 'out' and not scanned by the ECS, but still available verbatum, and would be useful for any component. Probably just a key -> component map.

portokaliu commented 7 years ago

@Weilin1992 Yes, that is correct. The component would be larger. This would be the case in what @OvermindDL1 is referring to as well.

So finally, it would come to a decision of modularity : either we create a way to deactivate components ( which will imply a lot of changes, but be far greater in scope and useful overall imo ), or we create custom cases of "deactivated components", which will have to know to re-activate the normal components when they are removed and such.

syntaxi commented 7 years ago

Considering it's one of the benefits of an ECS I think that we should have a method to deactivate components. Having a look at the code it doesn't seem overly hard to add in this functionality, however it will depend on how it should be implemented. I've opened a new issue (#2896) for that

Aizen93 commented 5 years ago

Hello, every one So i'm new to Terasology and i'm trying to solve one of the "Good first issue" to get started, and i was wondering if this topic is closed or not yet(I see some issues here are closed but not the entire issue 2837)? so what kind of commands you still need precisely, can i have some more details please? I would love to try this one and share with you :)

Cervator commented 5 years ago

Hi @Aizen93 ! Sorry for the delayed greeting :-)

We were just brainstorming something related to this topic earlier, but on the other side of things: causing healing or blocking it under certain circumstances. Fun diagram! https://sketchboard.me/xBtKY4tnIqzo#/

I wonder if rather than worry about all this component deactivating or not we can simply go and capture then cancel the damage equivalent version of BeforeHeal on that diagram. So maybe BeforeDamagedEvent

If you make an event handler (lots of good examples scattered around the code base, come say hi on chat for more if you like!) that captures that event and cancels it (uses .consume() on the event) then that might be enough to eliminate damage. The console command could attach a DamageImmunityComponent or even DamageResistanceComponent (if we want to support damage resistance more generally rather than just immunity - you can easily achieve that anyway by setting the resistance to 100%) to the player entity that uses the command, then the event handler could look for the presence of such a component on the entity being damaged to determine whether to cancel the event or even just reduce its damage.

Does that help? This is a real quick blurb as I'm just dashing between topics, but come say hi on Discord for more if you have any questions at all! :-)

Aizen93 commented 5 years ago

Thank you for your answer, I will introduce my self on the forum and i'll try coming to discord to learn more. As for the issue i think this is a good start i just need to understand the architecture of the code first and the diagram is very helpful, thanks a lot.

EaguaireSama commented 5 years ago

Hey, I'm a Beginner too and I'm looking for something easy to fix. Can anyone tell me if this issue is still open? Because it seems like @Aizen93 is working on it.If that's not the case then I'd like to have a shot at fixing it.

Aizen93 commented 5 years ago

@EaguaireSama you can work on it. I'm currently on the blender addon issue. Sorry for not mentionning it. I learned the code trying to solve it, but ended up doing other things :)

Ps: physical damage immunity is easy to implement. But there are other sources of damage. To be 100% immune you need to find all possible sources of damage and block them(items, drowning...etc) Good luck.

EaguaireSama commented 5 years ago

Oh great. And thanks a lot for the tip.

EaguaireSama commented 4 years ago

https://github.com/Terasology/Health/pull/32

EaguaireSama commented 4 years ago

solved?

Cervator commented 4 years ago

Yep! Good catch. Closing as complete :-)