• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] Add attribute to damage

Status
Not open for further replies.
Level 3
Joined
Jan 13, 2011
Messages
33
This should be simple... but I'm not quite sure how to do it since I haven't started tweaking with attribute-triggering-stuff yet.
I want to create a spell that adds one of your attributes to your damage for a specific period of time.
For example, when the unit starts the effect of the ability and let's say it's strenght is 34, I want to add +34 damage to that unit for an X period of time.
 
Level 6
Joined
Sep 27, 2008
Messages
258
it is really simple it will be like this in the trigger as i know at least, but there may be better ways
you have to make a variable that is a REAL type for Set SpellDmg
  • Untitled
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YourSpell
    • Actions
      • Set SpellDmg = (Real((Strength of (Triggering unit) (Include bonuses))))
      • Unit - Cause (Triggering unit) to damage circular area after 0.00 seconds of radius 200.00 at (Position of (Triggering unit)), dealing (5.00 x ExplosivePunchDmg) damage of attack type Spells and damage type Normal
 
Level 7
Joined
Jun 16, 2008
Messages
327
Hey there, The_Holy_Raider!
I see Utha has already provided a helpful solution to your problem, and I thank him for doing so. However, I would just like to add one of my own, just in case it's the unit's base damage itself that you want to enhance with the attribute.

It involves creating a 'pseudo-ability' (an ability that exists in the editor, but can't be seen in-game. It does, however, still have an effect in-game). This 'pseudo-ability' would be a constant passive ability - such as command aura (abilities such as auras and attribute bonuses are examples of passive abilities) - but would only apply to the hero itself. It will have many levels - say about 50. Why? Because each level represents the amount of attribute points. What do I mean? Let's say the hero's strength is 20, and you want his damage to be increased by 20. You'd make that pseudo-ability level 20, since that's how many strength points the hero has.

So the first thing you can do is: Create a new ability in the object editor, based on a passive, damage-increasing ability, such as command aura. Then, make it so that there are about 50 or so levels. Then, make it so that the ability affects only the hero. Do this by making the 'targets allowed' field only contain 'self'. Then, make it so that the damage enhancement is proportional to the ability's level. (e.g: Level 1 gives +1 damage, level 2 gives +2 damage, level 3 gives +3 damage, and so on)
Then, be sure to make sure the player can't see the pseudo-ability. You can do this by removing its icons and so on, making the ability 'invisible' in the interface. Don't worry about in-game descriptions and all that other nonsense - the player shouldn't see it, so simply leave those fields blank. Of course, if you want, you can also remove and buffs or other graphic effects, too.
(The only restriction with this method is that the unit has to have 'space' for another ability.)

Once the ability has been created, now it's time for some triggering.
What you want to do is add that pseudo-ability whenever the REAL ability (the one that causes the damage to be increased) is cast.
Here's the solution in simple GUI (I'll explain it subsequently):

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to <YourSpell>
  • Actions
    • Unit - Add <Pseudo-Ability> to (Casting Unit)
    • Unit - Set level of <Pseudo-Ability> for (Casting unit) to (Strength of (Casting Unit)(Exclude bonuses))
After that, just create a trigger that removes the pseudo-ability once the REAL ability has worn off. This can be accomplished with a simple timer that is proportional to the amount of time the REAL ability is active.

Voila! This should work, but I haven't tested it, so, please, if you do try it, please do provide feedback. If you encounter any problems, please send me a PM, or simply post in this thread, and I, or any other helpful modder, will be sure to assist you.

Remember, "nothing is impossible!"
 
Level 3
Joined
Jan 13, 2011
Messages
33
First of all I would like to thank utha for his comment, but unfortunately what I was thinking of was different... I don't want the spell to cause damage in an area or a target with the damage derriving from the attribute value... instead what I meant was to add bonus damage to that unit by that value.
Elite Slayer, thank you for answering as well. Your answer was more accurate but I would like to ask a question: If I do add the pseudo-ability, won't it appear in the hero's abilities? I wouldn't like the unit to suddenly have one more ability when the regural one is cast...
 
Level 7
Joined
Jun 16, 2008
Messages
327
I understand your concern - after all, it would be quite displeasing and unappealing to have another ability to suddenly appear. It's been quite a while since I last created a pseudo-ability, and so I'm not entirely sure, however, I would place a bet on this: simply remove its icons, buffs and toolbar descriptions (all the fields with the 'Test -' prefix). In essence, make sure all the 'Art -' fields have null/zero values. This should make the icon 'invisible.' If it doesn't, though (there's a chance it may still be visible with a 'green' icon indicating a missing icon), I'll be trying it out in a map of my own, and I'll see if I can find a correct solution for you. I'll keep you updated if I do.

EDIT::
In case it doesn't work, I did some searching around, and I came across this thread at The Helper.net, which deals with an issue that is extremely similar, if not the same -> Click
It suggests creating a trigger that hides the ability by enabling and then disabling it rapidly. The poster states that this hides the ability, but still allows it to retain its effects. If my method doesn't work in that regard (hiding the ability), I believe it could be worth a shot trying his.
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
Add the passive spell into a spell book,about the ability, make 4 ability
With 10 level each
Set the first ability give 1 to 9 damage
Set the second ability give 10 to 99 damage
Set the third ability give 100 to 999 damage
Set the fourth abilit give 1000 To 9999 damage, then add the 4 ability into one hero, i'll give a test map asap i got home
 
Level 7
Joined
Jun 16, 2008
Messages
327
Add the passive spell into a spell book,about the ability, make 4 ability
With 10 level each
Set the first ability give 1 to 9 damage
Set the second ability give 10 to 99 damage
Set the third ability give 100 to 999 damage
Set the fourth abilit give 1000 To 9999 damage, then add the 4 ability into one hero, i'll give a test map asap i got home

Innovative, and you can hide a spellbook, but that would be making an unnecessary amount of abilities - why use four, when you can just use one? And that could result in the hero getting (1 to 9) + (10 to 99) + (100 to 999) + (1000 to 9999) damage, which would almost turn him into Chuck Norris. And it would be nearly impossible to set a fixed amount based on the attribute.
 
Level 7
Joined
Jun 16, 2008
Messages
327
It's true, that would take some time. But just how do you intend to specify an exact amount with which to increase damage, if you have four abilities with one level? That's impossible. Besides, what guarantee is there that the heroes in his map have attributes that extend beyond 100 points? None so far, and thus it would be far more appropriate and suitable to make a single ability with levels that are easy to change, and that would take a few measly minutes to configure, than for the long time it would take trying to figure out how to make things work with four one-level abilities. On top of that, it would appear that, by his willingness to use the method I provided, he doesn't, so far, see anything wrong with it as you have.

Anyways, I think this has already been solved.
 
Level 11
Joined
Dec 5, 2009
Messages
846
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacking unit) has buff YOURBUFF) Equal to True
        • Then - Actions
          • Unit - Cause (Triggering unit) to damage (Attacked unit), dealing (Real((Strength of YOURUNIT (Include bonuses)))) damage of attack type Normal and damage type Normal
        • Else - Actions
Here you need to use a buff that triggers this trigger.
But it might look a bit ugly, i guess the damage will come like a milisecond before or something.
 
Level 3
Joined
Jan 13, 2011
Messages
33
Thanks to everyone for answering.
What I think I'll do afterall, will be a variation of Elite Slayer's suggestion: make a trigger that whenever a unit starts the effect of my ability, add an ability to it with it's level equal to the casting unit strenght. I'm not sure this will work, but if I base that ability on Item Damage Bonus, the icon should be hidden properly. But taking the time to make levels for every ammount of strenght the unit can reach will be exhausting...
I will also try Chewii's approach. It sounds logical.
 
Level 3
Joined
Jan 13, 2011
Messages
33
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacking unit) has buff YOURBUFF) Equal to True
        • Then - Actions
          • Unit - Cause (Triggering unit) to damage (Attacked unit), dealing (Real((Strength of YOURUNIT (Include bonuses)))) damage of attack type Normal and damage type Normal
        • Else - Actions
Here you need to use a buff that triggers this trigger.
But it might look a bit ugly, i guess the damage will come like a milisecond before or something.

What if before placing Cause damage I added a Wait for X seconds, with X being equal to the attack animation time of the unit?
 
Level 11
Joined
Dec 5, 2009
Messages
846
Well you shouldn't use waits, what if a unit hits every sec and another unit hits every 2nd sec. Use this instead its better than waits.

Trigger1.

  • YourTrigger1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YOURABILITY
    • Actions
  • -------- If this is a specific unit then use this trigger if it is not then create a unit group and pick all units if you want it to be anyunit. If you don't know how to do it then ask me again. --------
    • Trigger - Add to (TRIGGER2) the event (Unit - (YOURUNIT2) Takes damage)
    • Trigger - Turn on YourTrigger2 <gen>
Trigger2.

  • YourTrigger2
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Damage source) has buff YOURBUFF) Equal to True
        • Then - Actions
          • Unit - Cause (Triggering unit) to damage (Triggering unit), dealing (Real((Strength of No unit (Include bonuses)))) damage of attack type Normal and damage type Normal
        • Else - Actions
          • Trigger - Turn off (This trigger)
I guess this will work just fine :)

If you don't understand ask me again!
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Well, it'd just be this line of custom script-

call AddUnitBonus(GetTriggerUnit(),BONUS_STRENGTH,GetHeroStr(GetTriggerUnit(),false))

The false at the end means to not include bonuses when retrieving hero strength. Can set it to true if wanting to include bonuses from things like items =)

The above sets it based on strength, but you can also do intelligence of agility
GetHeroAgi
GetHeroInt


Bonus requires vJASS and the Lua framework
http://www.hiveworkshop.com/forums/...ing-up-newgen-we-intro-trigger-editor-188349/
http://www.hiveworkshop.com/forums/...art-guide-installing-lua-scripts-easy-195612/
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
For a bonus dmg and if your setting the level base it of Item+Bonus damage Then use a string to integer to calculate damage values. WIth a string Collection temp variable
Have 4 abillities each one conrresponding to 4 diffrent item bonus damage for each decimal digit

If higher add 1 more thus you have 5digit numbers Etc

Thus you dont need to make many levels but really 9 for each digit and 5 abillities etc etc.

As everyone has already said.

Just to chip in . Dont use when a hero starts casting an abillity use Finish or there is a bug where they can stop the spell midway and redo spell without losing mana but dmg still going through..
An Alternative to that is make the spell have a cast time
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
Surely levels would be easier though. Stacking doesnt seem right cause then you have to figure out what to stack . Doesnt that mean long coding? Also powers of 2 have alot more abillities than with digits
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Surely levels would be easier though. Stacking doesnt seem right cause then you have to figure out what to stack . Doesnt that mean long coding?

Not at all.. this is what Bonus systems do.


Does this code look long to you for this design?
JASS:
    function SetUnitBonus takes unit u, integer b, integer v returns nothing
        local boolean n = v<0
        set b=b+pm[b]
        if (not n) then
            call UnitRemoveAbility(u,bd[b])
        else
            set v=v-pw[b]
        endif
        set b=b-1
        loop
            if (v>=pw[b]) then
                call UnitAddAbility(u,bd[b])
                call UnitMakeAbilityPermanent(u,true,bd[b])
                set v=v-pw[b]
            else
                call UnitRemoveAbility(u,bd[b])
            endif
            exitwhen pm[b]!=0
            set b=b-1
        endloop
        if (n) then
            call UnitAddAbility(u,bd[b+pm[b]])
            call UnitMakeAbilityPermanent(u,true,bd[b+pm[b]])
        endif
    endfunction

And that includes negative bonuses and goes up to w/e value you want =).

edit
Also powers of 2 have alot more abillities than with digits

That's true, but it's less data over all.

With digits, up to 99,999, you'd have to have 5 abilities and 9 levels per ability >.>. 5*9 = 45 rather than 16 abilities with a bigger range.

What makes more sense?
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
Very short actually. But now im consfused how this works. Because surely after 16 its
16+1
16+2
16+2+1
16+4
16+4+1
16+4+2
16+4+2+1
etc
16+8
16+8+1
etc
16+8+4+2+1
32
So every time you go 2 4 8 16 32 64 etc each double---- You need to use a whole new abillity for each double. Doesnt this mean if you go to like 5000dmg+ you get like 10+ abillities.
While with Digits you get only 4
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
Why cant they be widgetized if your just converting to a string... Surely strings can have any length.
They have levels so levels of 2 Or? if so then now i understand and ty for enlightening me ^^
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
The range of values you can have is -(2^power+1) to (2^power+1)-1

For example, 15 abilities would allow you to go from -65536 to 65535

20 would let you do -2097152 to 2097151


This is the best possible way to add bonuses to units =).



The Bonus system I created does this all for you. It automatically generates the abilities, lets you pick how big a range you want, and lets you even pick what kind of bonuses you want ^)^. I suggested it because it looks like the op only needed damage, so he could just disable everything and keep damage enabled. I also think he'd prob only need to go up to like a power of 11, so 11 abilities total ; )
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
So surely with 10 digits it used less data as there is only 5 abillities for that range . Also every abillity takes up data to create //I.e For model and item etc and space...

But yeh i see the rangeabillity with 2 digits and the nice stacking system.
 
Status
Not open for further replies.
Top