Announcement

Collapse

Forum Rules

  • No flaming or derogatory remarks, directly or through insinuation.
  • No discussion, sharing or referencing illegal software such as hacks, keygen, cracks and pirated software.
  • No offensive contents, including but not limited to, racism, gore or pornography.
  • No excessive spam/meme, i.e. copious one liners in a short period of time, typing with all caps or posting meme responses (text/image).
  • No trolling, including but not limited to, flame incitation, user provocation or false information distribution.
  • No link spamming or signature advertisements for content not specific to Dota 2.
  • No Dota 2 key requests, sell, trade etc.
  • You may not create multiple accounts for any purpose, including ban evasion, unless expressly permitted by a moderator.

  • Please search before posting. One thread per issue. Do not create another thread if there is an existing one already.
  • Before posting anything, make sure you check out all sticky threads (e.g., this). Do not create new threads about closed ones.
  • It is extremely important that you post in correct forum section.

  • Balance discussion only in Misc.
  • All art related (such as hero model) feedbacks go to Art Feedback Forum.
  • All matchmaking feedback should go here: Matchmaking Feedback
  • All report/low priority issues should go here: Commend/Report/Ban Feedback
  • No specific workshop item feedback. These should go to workshop page of that item.
  • When posting in non-bugs section (such as this), use [Bugs], [Discussion] or [Suggestion] prefix in your thread name.



In case you object some action by a moderator, please contact him directly through PM and explain your concerns politely. If you are still unable to resolve the issue, contact an administrator. Do not drag these issues in public.



All rules are meant to augment common sense, please use them when not conflicted with aforementioned policies.
See more
See less

OnDamageTaken event needs more information

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • OnDamageTaken event needs more information

    Currently the event lists
    • Attacker
    • Caster (of the ability)
    • Unit (that casted)
    • Script
    • Damage
    • Function called
    • Ability


    It really needs stuff like damageType and unmitigated damage.

    Currently we can't make spells that react to different types of damage (e.g. reflect some % of magic damage) - which really limits our creativity when it comes to defensive abilities. I assume that recreating a spell like Flame Guard would be impossible with the current event.

    Thanks!

  • #2
    I ended up making my own ApplyDamage function to overcome this constraint, but surely this is disturbing for fresh modders

    +1

    Comment


    • #3
      In ability_lua event MODIFIER_EVENT_ON_TAKEDAMAGE have damageType and unmitigated damage

      Comment


      • #4
        Originally posted by K1dney View Post
        In ability_lua event MODIFIER_EVENT_ON_TAKEDAMAGE have damageType and unmitigated damage
        Oh excellent - how do I go about using that? If you don't mind me asking - is there an example somewhere I can check out?

        Comment


        • #5
          Level5Pidgey,

          Is this in regards to an ability_datadriven event?

          Thanks.

          Comment


          • #6
            Originally posted by Kyle View Post
            Level5Pidgey,

            Is this in regards to an ability_datadriven event?

            Thanks.
            I'm not 100% on the lingo (only started modding this week) - but yes, the ability as defined in the KV file is data driven, and has a modifier defined beneath it. The modifier has an "OnDamageTaken" event in it, like so (I made this as generic as possible to help highlight the structure):

            Code:
            "custom_ability_shield"
            {
            	"BaseClass"						"ability_datadriven"
            
            	"AbilityBehavior"				"DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_TOGGLE | DOTA_ABILITY_BEHAVIOR_IMMEDIATE"
            	
            	"OnToggleOff"
            	{
            		"RemoveModifier"
            		{
            			"ModifierName"	"modifier_shield_active_datadriven"
            			"Target" 		"CASTER"
            		}
            	}
            
            	"OnToggleOn"
            	{
            		"ApplyModifier"
            		{
            			"ModifierName"	"modifier_shield_active_datadriven"
            			"Target" 		"CASTER"
            		}
            	}
            
            
            	"Modifiers"
            	{
            		"modifier_conversion_shield_active_datadriven"
            		{
            			"OnTakeDamage"
            			{
            				"RunScript"
            				{
            					"ScriptFile"	"spells/custom_shield.lua"
            					"Function"		"shield_doThings"
            					"Damage"		"%attack_damage"
            				}
            			}
            		}
            	}
            }

            In my lua:
            Code:
            function shield_doThings( event )
            
            	for k,v in pairs(event) do
            	    print(k,v)
            	end
            end
            When I get attacked, console logs:
            Code:
            [   VScript              ]: caster_entindex	151
            [   VScript              ]: attacker	table: 0x03808318
            [   VScript              ]: caster	table: 0x037c7c58
            [   VScript              ]: unit	table: 0x037c7c58
            [   VScript              ]: ScriptFile	spells/custom_shield.lua
            [   VScript              ]: Damage	44.452346801758
            [   VScript              ]: Function	shield_doThings
            [   VScript              ]: ability	table: 0x0385ea78
            There is no damageType, etc.
            Last edited by Level5Pidgey; 06-26-2015, 10:53 PM.

            Comment


            • #7
              This is only tangentially related, but note that "%attack_damage" will pass in mitigated or unmitigated damage values depending on the modifier event.

              OnAttackLanded - The unit this modifier is attached to has landed an attack on a target. "%attack_damage" is set to the damage value before mitigation. Autoattack damage is dealt after this block executes.
              OnDealDamage - The unit this modifier is attached to has dealt damage. "%attack_damage" is set to the damage value after mitigation.
              OnTakeDamage - The unit this modifier is attached to has taken damage. "%attack_damage" is set to the damage value after mitigation.
              The all-in-one damage filter has largely superseded these modifier events because more information is provided to it, but if they are going to be fixed up to provide mitigated/unmitigated damage and damage type, then it would be nice to also have some indication of whether an autoattack or an ability caused the damage (an ability's hscript could be passed in, for example).

              Comment

              Working...
              X