• 🏆 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!

Damage based on current attribute

Status
Not open for further replies.
Level 2
Joined
Apr 8, 2009
Messages
21
Hello Hive! I've been trying to get this trigger to work for about an hour now, as I've got a floating damage number system working now, so I'm happy with that. The background is, the spell (based on Firebolt) deals 0 damage, and the damage is calculated through this trigger (so it has scaling damage rather then static damage). I used those temp variables to make it easier for me to add new spells later on (I can just edit each of those faster then opening up the Unit - Cause action).

  • SpellFirebolt
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Firebolt
    • Actions
      • -------- Create a temporary variables --------
      • Set tempAttribute = (Intelligence of (Casting unit) (Include bonuses))
      • Set tempAttributeModifier = 2
      • Set tempInteger = (tempAttribute x tempAttributeModifier)
      • -------- Apply damage --------
      • Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing (Real(tempInteger)) damage of attack type Spells and damage type Normal
      • -------- Reset values --------
      • Set tempAttribute = 0
      • Set tempAttributeModifier = 0
      • Set tempInteger = 0
Anyway, when I use that script things work well, however since the event is Beings casting an ability, it happens in instant the character is within range, before the projectile even reaches the target.

I've tried switching it to Unit - A unit Finishes casting an ability however this doesn't work; no damage is dealt and no floating text. Any ideas?

Just as a random thought; rather then having a seperate trigger for each spell, would it be possible to assign custom values to a spell, that could be checked later (so I could assign Str (0)/ Agi (1)/ Int (2) and the modifier)? Then I could have one trigger that would handle all of my spells... Might make things faster.

Also, I'm wondering if there was a program/tool that checks leaks for me? Leak Check 3.1 is outdated and I'm trying to keep things as leakfree as possible.

Anyway, thanks in advance for your help!
 
Level 9
Joined
Jul 10, 2011
Messages
562
you have to trigger the movement of the projectile to get when it hits the target.

also you could use a buff check (every buff have to be unique).

or you could use a projectile system.
 
You need to factor in projectile speed and wait for that amount. For example, if projectile speed is 1500, calculate how long it takes for the projectile to get to the target. However, waiting will make another problems here, since you will have to use local variables, so it will be problematic, not to mention the fact that if the unit moves, the value changes.

I am not sure how you mean the thing with custom values, though it would be extremely easy to do with jass. You're quite lucky, though, since I need to create such a system for myself, so I will share it with you (since we need the same thing) once complete.

As for leaks, you will need to fix them yourself, that's the only sane way to do it, though I believe there's a script in our spells section that provides leak checking.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
For the event, you need to use Unit Starts the Effect of an ability, which is usually somewhere during the animation.

Now for the timing problem, if you don't want to hassle with projectile systems, here's what I suggest:
Create a dummy unit when the spell is cast, and give this dummy unit the same missile art as the spell. Set its base damage to 0.
Set the dummy's damage during your trigger by either adding an ability that gives damage and changing the level, or having the dummy based on a hero unit, and setting its base attribute.
Don't forget to add an expiration timer to your dummy unit, and to remove it when it dies.
 
Level 2
Joined
Apr 8, 2009
Messages
21
HappyTauren, I was thinking exactly that (I created my original post at like 1:30 in the morning so not 100% with it); but am I able to get the value of a spell in JASS? I've been looking through the GUI to get that variable, but I can't seem to find it.
 
Why don't you put the value in the name? Like, check if the spell's name starts with a special character, and if it does, read the number. For example, if you had a firebolt spell, you can leave tooltips intact while the spell's name is _1_Firebolt. First you check if the spell is indexed (check the first character of the name) and if it is, start reading the characters (using a substring) until you reach "_". That's how you can set spell's name to _24_Frostbolt and have it indexed with the number 24. I am actually going to write a script that works with this, but it is late today, gonna start tomorrow.
 
Level 2
Joined
Apr 8, 2009
Messages
21
Why don't you put the value in the name? Like, check if the spell's name starts with a special character, and if it does, read the number. For example, if you had a firebolt spell, you can leave tooltips intact while the spell's name is _1_Firebolt. First you check if the spell is indexed (check the first character of the name) and if it is, start reading the characters (using a substring) until you reach "_". That's how you can set spell's name to _24_Frostbolt and have it indexed with the number 24. I am actually going to write a script that works with this, but it is late today, gonna start tomorrow.

I just created a system that checks it (so for example A2Backstab would be Agility, with an attribute modifer of x2). Thanks for that, but I've got another problem. When I get that Firebolt ability to my mage, it shows up and deals the damage (as it should), but when I give it to my Archer hero that I've got, the ability gets cast and you can see the projectile, but there's no damage dealt!

  • CombatSpellFirebolt
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Value
    • Actions
      • -------- Time to be waited before calculating damage --------
      • Set tempInteger = 1
      • Wait (Real(tempInteger)) game-time seconds
      • -------- Calculate which attribute to use --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Substring((Name of (Ability being cast)), 1, 1)) Equal to (==) A
          • Then - Actions
            • Set tempAttribute = (Agility of (Casting unit) (Include bonuses))
            • Game - Display to (All players) for 30.00 seconds the text: Agility
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Substring((Name of (Ability being cast)), 1, 1)) Equal to (==) I
          • Then - Actions
            • Set tempAttribute = (Intelligence of (Casting unit) (Include bonuses))
            • Game - Display to (All players) for 30.00 seconds the text: Intelligence
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Substring((Name of (Ability being cast)), 1, 1)) Equal to (==) S
          • Then - Actions
            • Set tempAttribute = (Strength of (Casting unit) (Include bonuses))
            • Game - Display to (All players) for 30.00 seconds the text: Strength
          • Else - Actions
      • -------- Calculate attribute modifier --------
      • Set tempAttributeModifier = (Integer((Substring((Name of (Ability being cast)), 2, 2))))
      • Game - Display to (All players) for 30.00 seconds the text: (String(tempAttributeModifier))
      • -------- Create a temporary variables --------
      • Set tempInteger = (tempAttribute x tempAttributeModifier)
      • -------- Apply damage --------
      • Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing (Real(tempInteger)) damage of attack type Spells and damage type Normal
      • -------- Reset values --------
      • Set tempAttribute = 0
      • Set tempAttributeModifier = 0
      • Set tempInteger = 0
[/SPOILER]

When the Archer uses the ability, you can see 'Intelligence' and '2' pop up (since the name is I2Firebolt), but no damage, so I'm actually confused!
 
Level 2
Joined
Apr 8, 2009
Messages
21
Waits really suck big time, I am sure all bugs you have are because of that "wait".

Well, I'm going to (re)make an entire combat system (so no only are damage spells calculated by attributes but I'll be able to manage element types (like I could calculate a spell using an attribute but then be able to add extra damage if that unit is weak agaisnt that element or something). Just wondering for anyone that's actually done it, but is it possible to create a floating number combat system in JASS, that's calculated from the unit dealing damage rather then the unit that's taking damage, because in my map i'd assume it's going to be alot more efficient and effective to calculate it from one to ten heroes then like 1000 enemies.
 
Status
Not open for further replies.
Top