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

Time and Variables based on Heroes atributs

Status
Not open for further replies.
Level 2
Joined
Jun 14, 2013
Messages
23
Hello

I would like to know if and how can i change a time based on an heroes attribute.
Ex.
I want an hero to deal damage to a target (using triggers) every 2 seconds - his intellect/100. (final value is bigger than zero ofc).

ive tried by doing the math in the time trigger line, but it escalated very fast.. like the time became almost instant. now im trying to set a variable when the ability is casted and use that variable as time.

Want it to work a bit like haste for spells.

Thank you.
 
Level 2
Joined
Jun 14, 2013
Messages
23
Nothing that fancy, im tying a very simple way.
  • tag holy fire
    • Events
      • Unit - Holy Knight 0047 <gen> Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Knight - Holy Fire lvl 6
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Holy_Knight_Holy_Fire_1 has buff Holy Knight - Holy Fire ) Not equal to True
        • Then - Actions
          • Set Holy_Knight_Holy_Fire_1 = (Target unit of ability being cast)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Holy_Knight_Holy_Fire_2 has buff Holy Knight - Holy Fire ) Not equal to True
            • Then - Actions
              • Set Holy_Knight_Holy_Fire_2 = (Target unit of ability being cast)
            • Else - Actions
              • Do nothing
      • Set Holyknigh_Holyfire_haste = ((Intelligence of Holy Knight 0047 <gen> (Include bonuses)) / 100)

  • holy fire damage 1
    • Events
      • Time - Every 1.20 seconds of game time
      • Time - Every ((250.00 - (Real((Intelligence of Holy Knight 0047 <gen> (Include bonuses))))) / 100.00) seconds of game time
      • Time - Every (3.00 - ((Real((Intelligence of Holy Knight 0047 <gen> (Include bonuses)))) / 100.00)) seconds of game time
    • Conditions
      • (Holy_Knight_Holy_Fire_1 has buff Holy Knight - Holy Fire ) Equal to True
    • Actions
      • Unit - Cause Holy Knight 0047 <gen> to damage Holy_Knight_Holy_Fire_1, dealing ((Real((Intelligence of Holy Knight 0047 <gen> (Include bonuses)))) x 1.00) damage of attack type Magic and damage type Magic
      • Special Effect - Create a special effect attached to the overhead of Holy_Knight_Holy_Fire_1 using Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
  • holy fire damage 2
    • Events
      • Time - Every 1.20 seconds of game time
      • Time - Every (3.00 - ((Real((Intelligence of Holy Knight 0047 <gen> (Include bonuses)))) / 100.00)) seconds of game time
      • Time - Every ((250.00 - (Real((Intelligence of Holy Knight 0047 <gen> (Include bonuses))))) / 100.00) seconds of game time
    • Conditions
      • (Holy_Knight_Holy_Fire_2 has buff Holy Knight - Holy Fire ) Equal to True
    • Actions
      • Special Effect - Create a special effect attached to the overhead of Holy_Knight_Holy_Fire_2 using Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
      • Unit - Cause Holy Knight 0047 <gen> to damage Holy_Knight_Holy_Fire_2, dealing ((Real((Intelligence of Holy Knight 0047 <gen> (Include bonuses)))) x 1.00) damage of attack type Magic and damage type Magic
 
Level 2
Joined
Jun 14, 2013
Messages
23
Ok, i thought it would also copy the "not used" lines.

in both holy fire damage (1 and 2) im only using 1 of the events at a time ofc. the other 2 are disabled.
 
Level 8
Joined
Jul 8, 2013
Messages
249
So if I understood you correctly, the problem you have is that the trigger doing the damage happens more often that you want it to? Basically because your 3- (Int/100) ends up being very small (Presumably meaning the Int is over 200)?.

Well the most obvious suggestion is to just change your formula. For example, if you don't want the damage to be applied more than, say, 10 times per second then you could change the periodic event to occur every Max(( 3 - (Int/100)), .1) seconds of game time. That way it would happen every 3- (Int/100) seconds as long as that would not be more than 10 times per second but would never occur more than 10x per second.

If that's not the problem you have, then can you please explain more clearly what you want the ability to do and what the problem with it is?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Maybe you dont understand what trigger events are.

You have 3 events on your damage trigger.
  • Time - Every 1.20 seconds of game time
  • Time - Every ((250.00 - (Real((Intelligence of Holy Knight 0047 <gen> (Include bonuses))))) / 100.00) seconds of game time
  • Time - Every (3.00 - ((Real((Intelligence of Holy Knight 0047 <gen> (Include bonuses)))) / 100.00)) seconds of game time
This means that every time any of those are called, your trigger runs.

So this trigger will run every 1,2 seconds
and this trigger will run every 3 - (formula) seconds
and this trigger will run every (250 / (formula) seconds.

For example I have a hero with 50 intelligence.
Then that trigger runs every 1.2 seconds
and that trigger runs every 2 seconds ((250 - 50) / 100)
and that trigger runs every 1 seconds. (3 - (50 / 100))

if you calculate those things then you see that per second this trigger is called
0,83 X per second
0,5 X per second
1 X per second
So that trigger will run 2,33 times per second with random intervals.

And if you have 2 of those (it seems you have 2) then it will be 4,66 times per second with random intervals.
I guess that that is what your problem was.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

I strongly suggest making a loop where a unit deals damage to a unit with a polled wait time calculated to the intelligence.
Ofcouse you have to do that in JASS if you want it to be flawless but it is quite simple.

Let it run on Map Initialization.
Set a local unit variable target and hero to the target unit and the hero that deals the damage.

Then make a loop with the damage event and a polled wait and let it stop when the target unit is dead (or whatever you want.) Also stop it when the hero is dead.

kinda like this:
JASS:
function DamageTarget takes nothing returns nothing
    local unit target = gg_unit_n00A_0047
    local unit hero = gg_unit_n00A_0047
    
    loop
        call PolledWait(3 - (I2R(GetHeroInt(hero)) / 100))
        call UnitDamageTargetBJ(hero, target, (I2R(GetHeroInt(hero)) * 1), ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC)
        exitwhen (GetUnitStateSwap(UNIT_STATE_LIFE, target) < 1)
        exitwhen (GetUnitStateSwap(UNIT_STATE_LIFE, hero) < 1)
    endloop
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger()
    call TriggerAddAction(gg_trg_Untitled_Trigger_001, function DamageTarget)
endfunction

You can make this trigger without any problem.
Just make a GUI trigger without events or conditions.
For actions do Kill Unit (hero) and Kill Unit (target)
So it will look like this:
  • Untitled Trigger 002
    • Events
    • Conditions
    • Actions
      • Unit - Kill Dummy 2 0278 <gen>
      • Unit - Kill Dummy Villager (Male 2) 0000 <gen>
Then select that trigger in the list of triggers on the left side of the screen and go to Edit - Convert to custom text (it is in the menu on top of the screen.)
Then your trigger is made in JASS.
JASS:
    call KillUnit( gg_unit_h00T_0278 )
    call KillUnit( gg_unit_n000_0000 )
Then you see the call KillUnit actions. Copy the "gg_unit_aaaa_0000" from those. They are the unit.
Set those to the local unit gg_unit_fasf_9401 in the trigger i showed before.
This should work.
 
Last edited:
Level 12
Joined
Oct 16, 2010
Messages
680
Wietlol before u post u should read the above posts. He told that he only use one event at a time.Also polled waits are bad , kill unit is bad maybe he uses dds and converting GUI to pure jass without enough knowledge is bad.


I would say that the formula u have with the 3 sec is ok but u should store the pre calculation of it and use the variable in the event

This spell is mostly depends on how fast u want to lower the time between periods and actually how much a int your hero can get during the game mostly and for maximum.

Say that your hero can get 300 int max and u want that to decrease the period time by 1 sec in total

According to these circumstances the formula should be 3-(int/300)

U can play along with the numbers but it's up to u to find the balance
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
According to these circumstances the formula should be 3-(int/300)
Just don't forget that '3' is not '3.00' - the first is integer and the second real number. "3 - (int/300)" will return number 3 if int is less than 300 and 2 if int is in interval [300, 599] and so on since integer division uses remainders.
E.g.
Integer calculation 16/5 is 3 with remainder 1.
Real calculation 16.00/5.00 is 3.20
 
Level 12
Joined
Oct 16, 2010
Messages
680
Just don't forget that '3' is not '3.00' - the first is integer and the second real number. "3 - (int/300)" will return number 3 if int is less than 300 and 2 if int is in interval [300, 599] and so on since integer division uses remainders.
E.g.
Integer calculation 16/5 is 3 with remainder 1.
Real calculation 16.00/5.00 is 3.20

that only requires to convert the intellect from int to real and it shouldn't be a problem
 
Level 2
Joined
Jun 14, 2013
Messages
23
Thank you all for the help, could only see the forum now. i will try another thing and ill tell you after.
thank you
 
Status
Not open for further replies.
Top