. . . Posted November 12, 2016 Share Posted November 12, 2016 (edited) Hello, I have a question . So, my question is would it be possible to get the value of damage my character took on the attacked event? Because there's stuff I want to do for my character depending on the amount of damage she took, if she took less than 25 damage, more than 50 damage, more than 100 damage ect. would that be possible ? If someones knows if that's possible & tells me that would be totally awesome!! Thanks so much for reading my question, have a great day/night !!! Edited November 13, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/ Share on other sites More sharing options...
Serpens Posted November 12, 2016 Share Posted November 12, 2016 (edited) ListenForEvent("healthdelta",function(inst,data) if data.amount>xy then ...end; end)) edit: just search all lua files for such events. It is really no magic You can also search for "Event(" to find all possible events and look if there is one that might be intersting for you. And then you will most like also find the PushEvent variant of it, were you can see what can be used. In this case: self.inst:PushEvent("healthdelta", { oldpercent = old_percent, newpercent = self:GetPercent(), overtime = overtime, cause = cause, afflicter = afflicter, amount = amount }) so you can check the cause if you want to. Edited November 12, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/#findComment-836628 Share on other sites More sharing options...
. . . Posted November 12, 2016 Author Share Posted November 12, 2016 (edited) 9 hours ago, Serpens said: self.inst:PushEvent("healthdelta", { oldpercent = old_percent, newpercent = self:GetPercent(), overtime = overtime, cause = cause, afflicter = afflicter, amount = amount }) This would check how much damage I take from entities, right ? Though how would I use this? I don't understand what to do with this code .. but thanks for your help Serpens !!! Edited November 12, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/#findComment-836761 Share on other sites More sharing options...
Serpens Posted November 12, 2016 Share Posted November 12, 2016 (edited) 4 hours ago, SuperDavid said: This would check how much damage I take from entities, right ? Though how would I use this? I don't understand what to do with this code .. but thanks for your help Serpens !!! ?! You use it like every other event. Not the code you quoted. Of course you use ListenForEvent I wrote above. The PushEvent is only mentioned so you can see what is included in "data". Edited November 12, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/#findComment-836814 Share on other sites More sharing options...
. . . Posted November 13, 2016 Author Share Posted November 13, 2016 1 hour ago, Serpens said: you use ListenForEvent I wrote above Okay, i'm really confused.. I did this inst:ListenForEvent("healthdelta", function(inst, data) if data.amount > 1 then inst.components.health:DoDelta(20) end end) and got this crash when I ate a bonestew" :495: stack overflow " also, the code never triggered when I got attacked. Also, isn't event "healthdelta" just a event that monitors the player's health level? I don't want at like my character is below 200 health something happens. What I want to try to do is for example if my character is hurt by a attack & that attack dealed more than 100 damage I want to make stuff happen regardless of how much health my character has left! Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/#findComment-836842 Share on other sites More sharing options...
Kzisor Posted November 13, 2016 Share Posted November 13, 2016 (edited) @SuperDavid, you basically wrote the following: Event Trigger: healthdelta if data.amount is greater than 1 then Call health:DoDelta(20) Go to Step 1 Calling components.helath:DoDelta(20) triggers the healthdelta event which called components.health:DoDelta(20) which triggers the healthdelta event.... Edit: You should probably look into this event if you're wanting to get damage when a player is attacked: self.inst:PushEvent("attacked", { attacker = attacker, damage = damage, weapon = weapon, stimuli = stimuli, redirected=damageredirecttarget }) Edited November 13, 2016 by Kzisor Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/#findComment-836847 Share on other sites More sharing options...
. . . Posted November 13, 2016 Author Share Posted November 13, 2016 10 minutes ago, Kzisor said: Calling components.helath:DoDelta(20) triggers the healthdelta event which called components.health:DoDelta(20) which triggers the healthdelta event.... What have I d-done ?! Haha, but I also did put something like inst:ListenForEvent("healthdelta", function(inst, data) if data.amount > 1 then inst.components.talker:Say("Wow, that totally hurt!") end end) and nothing happened, so even without that crash the event still does nothing ... Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/#findComment-836849 Share on other sites More sharing options...
Kzisor Posted November 13, 2016 Share Posted November 13, 2016 1 minute ago, SuperDavid said: What have I d-done ?! Haha, but I also did put something like inst:ListenForEvent("healthdelta", function(inst, data) if data.amount > 1 then inst.components.talker:Say("Wow, that totally hurt!") end end) and nothing happened, so even without that crash the event still does nothing ... *points to previous edit* Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/#findComment-836851 Share on other sites More sharing options...
. . . Posted November 13, 2016 Author Share Posted November 13, 2016 @Kzisor So, I would do something like this, yes ? inst:ListenForEvent("attacked", function(inst, data) if data.damage > 1 then inst.components.sanity:DoDelta(10) end end) Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/#findComment-836854 Share on other sites More sharing options...
Kzisor Posted November 13, 2016 Share Posted November 13, 2016 2 minutes ago, SuperDavid said: @Kzisor So, I would do something like this, yes ? inst:ListenForEvent("attacked", function(inst, data) if data.damage > 1 then inst.components.sanity:DoDelta(10) end end) Test it and find out, but you might also want to test for negative values as well. Link to comment https://forums.kleientertainment.com/forums/topic/71625-solved-possible-get-damage-value-when-players-attacked/#findComment-836856 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now