PaulCiclop Posted December 22, 2015 Share Posted December 22, 2015 (edited) I want my character has some damage against each type of enemy, like: spiders, frogs and others. I thank to show me an example of code to it. Sorry for the English google translator. Edited December 22, 2015 by PaulCiclop Link to comment https://forums.kleientertainment.com/forums/topic/61187-how-to-put-specific-damage-against-certain-monster/ Share on other sites More sharing options...
Mobbstar Posted December 22, 2015 Share Posted December 22, 2015 LIsten for the event "onattackother". inst:ListenForEvent("onattackother",function(inst,data) print(data.target) --puts prefab name to log.txtend) Note that this happens before the damage is calculated, so you can simply adjust the damage value in the function. Link to comment https://forums.kleientertainment.com/forums/topic/61187-how-to-put-specific-damage-against-certain-monster/#findComment-700443 Share on other sites More sharing options...
PaulCiclop Posted December 22, 2015 Author Share Posted December 22, 2015 LIsten for the event "onattackother". inst:ListenForEvent("onattackother",function(inst,data) print(data.target) --puts prefab name to log.txtend) Note that this happens before the damage is calculated, so you can simply adjust the damage value in the function.It is but, as does the definition of damage within the "inst: ListenForEvent (" onattackother "function (inst, date)"? Link to comment https://forums.kleientertainment.com/forums/topic/61187-how-to-put-specific-damage-against-certain-monster/#findComment-700513 Share on other sites More sharing options...
Mobbstar Posted December 22, 2015 Share Posted December 22, 2015 It is but, as does the definition of damage within the "inst: ListenForEvent (" onattackother "function (inst, date)"? I beg your pardon? I assume you ask for this: local damage_mult = 1 if data.target:HasTag("monster") or data.target.prefab == "pigman" then damage_mult = 1.5endinst.components.combat.damagemultiplier = damage_mult Link to comment https://forums.kleientertainment.com/forums/topic/61187-how-to-put-specific-damage-against-certain-monster/#findComment-700514 Share on other sites More sharing options...
PaulCiclop Posted December 22, 2015 Author Share Posted December 22, 2015 I beg your pardon? I assume you ask for this: local damage_mult = 1 if data.target:HasTag("monster") or data.target.prefab == "pigman" then damage_mult = 1.5endinst.components.combat.damagemultiplier = damage_multThank you so much. It worked perfectly. Do you happen to have a site to recommend where I can see the functions already implemented like the one you helped me? Link to comment https://forums.kleientertainment.com/forums/topic/61187-how-to-put-specific-damage-against-certain-monster/#findComment-700721 Share on other sites More sharing options...
pickleplayer Posted December 22, 2015 Share Posted December 22, 2015 Thank you so much. It worked perfectly. Do you happen to have a site to recommend where I can see the functions already implemented like the one you helped me? The link to the AP Idocs in his signature is a pretty useful site. http://dontstarveapi.marcosaviles.com/ Link to comment https://forums.kleientertainment.com/forums/topic/61187-how-to-put-specific-damage-against-certain-monster/#findComment-700829 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