• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Super imba hard to make spell

Status
Not open for further replies.
I wanna make a spell that cause units in 250 area to have their mana cap set to 100 for 10 seconds, which means any spells that required more than that will be unable to be cast.
The thing is: heroes have more than 100 cap :D and int is hard to controll since they have items :D.
So... without further edu: I gonna ask which way is the easiest and most buggless, please say your opinion:

1) Setting the hero int to int that sum up in 100 mana: the hero will have buff and whenever the buff removed the hero mana will be set to the diffult (starting int + int gain = bug since i need to use special settings for each hero since this skill is undetected) additiional bug: hero gain level gets int and there is gonna be trigger that remove the hero ability to gain int when level up.

2) Making the hero mana cap to -1000000 with item based skills, then giving him +100 with int based skill.
Problams: int gain mana cap, which is undetected...

3) making the hero have buff that check whenever he use a skill that cost more than 100 mana, then make him silenced for 10 seconds.
Problams: the spell was never intended to silence, just prevent high cost abilities. another problam: the mana for each spell will have to be set on setting since its undetectable.

4) making trigger that makes the hero mana set to 100 each and any 0.25 seconds.
problam: regeneration update faster than that, I wouldnt care if the hero gets 100 mana fast but its forbiden to ever get more than that.

Please give me your opinion about the best way to create this spell or give more options.
Thanks.
 
This would work.
  • No More Then 100
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) has buff Mana Flare) Equal to True)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Greater than 100.00
            • Then - Actions
              • Unit - Set mana of (Picked unit) to 100.00
            • Else - Actions
 
none of the above specially #1 & #2, but #4 seems OK, and the 0.03 is OK for the loop...

pick your units in 250AOE, set their mana to 100 (if their mana is above100)...
save 10 seconds to a hashtable...
add the unit to a group, loop the group for every 0.03 second, reducing the
saved real (this is the timer)...
in the loop, if mana is above 100, then set it to 100...

Im not at home at the moment so cant provide a test map, but I can if
you want it tonight, its not that hard...
 
Or you could check whenever an ability that costs over 100 mana is being cast, then issue order "STOP" to triggering unit.

how can mana cost be detected?

Note: I alllready created the skill and it is well made :D exept for the minor bug that removing the buff will not remove the mana regeneration pause, oh well, still wanna know if there is a way.
For those who wondered, I used #4 with some extra actions that allow multicasts and ally cast not to interfear with the mana return, after all, after the unit mana was set to 100, it will regain the mana it had in the first place with its costum value.
And, I used each 0.20 seconds, does that not quike enough?
If you want, I could play it with you :D so you see mckill2009
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
I wanna make a spell that cause units in 250 area to have their mana cap set to 100 for 10 seconds, which means any spells that required more than that will be unable to be cast.
The thing is: heroes have more than 100 cap :D and int is hard to controll since they have items :D.
So... without further edu: I gonna ask which way is the easiest and most buggless, please say your opinion:

1) Setting the hero int to int that sum up in 100 mana: the hero will have buff and whenever the buff removed the hero mana will be set to the diffult (starting int + int gain = bug since i need to use special settings for each hero since this skill is undetected) additiional bug: hero gain level gets int and there is gonna be trigger that remove the hero ability to gain int when level up.

2) Making the hero mana cap to -1000000 with item based skills, then giving him +100 with int based skill.
Problams: int gain mana cap, which is undetected...

3) making the hero have buff that check whenever he use a skill that cost more than 100 mana, then make him silenced for 10 seconds.
Problams: the spell was never intended to silence, just prevent high cost abilities. another problam: the mana for each spell will have to be set on setting since its undetectable.

4) making trigger that makes the hero mana set to 100 each and any 0.25 seconds.
problam: regeneration update faster than that, I wouldnt care if the hero gets 100 mana fast but its forbiden to ever get more than that.

Please give me your opinion about the best way to create this spell or give more options.
Thanks.

the solution is above...
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
how can mana cost be detected?

Note: I alllready created the skill and it is well made :D exept for the minor bug that removing the buff will not remove the mana regeneration pause, oh well, still wanna know if there is a way.
For those who wondered, I used #4 with some extra actions that allow multicasts and ally cast not to interfear with the mana return, after all, after the unit mana was set to 100, it will regain the mana it had in the first place with its costum value.
And, I used each 0.20 seconds, does that not quike enough?
If you want, I could play it with you :D so you see mckill2009

u could use a harder methode what modify the max mana so unit cant use potion or trick out

At map init, pls check the screenshot for makeing 2 ability but if u need only mana reduction then only 1 (ability based on item ability gain max mp)
  • Abilities2[1] = *your hp ability*
  • Abilities2[2] = *your mp ability*
To header
JASS:
//add/decrease hp or mp
function AddHPMP takes boolean HP, integer v, unit u returns nothing
    local integer a
    local integer s
    local integer i
    local integer l
    local integer cv
    local integer mv

    if HP then
        set a = udg_Abilities2[1]
    else
        set a = udg_Abilities2[2]
    endif

    if (v >= 0) then
        set s = 1
        set cv = v
    else
        set s = 5
        set cv = v * - 1
    endif
    set mv = cv - (cv / 1000) * 1000
    set l = cv / 1000
    set i = 1
    loop
        exitwhen i > l
        call UnitAddAbility( u, a )
        call SetUnitAbilityLevel( u, a, (4 + s) )
        call UnitRemoveAbility( u, a )
        set i = i + 1
    endloop
    set cv = mv
    set mv = cv - (cv / 100) * 100
    set l = cv / 100
    set cv = mv
    set i = 1
    loop
        exitwhen i > l
        call UnitAddAbility( u, a )
        call SetUnitAbilityLevel( u, a, (3 + s) )
        call UnitRemoveAbility( u, a )
        set i = i + 1
    endloop
    set mv = cv - (cv / 10) * 10
    set l = cv / 10
    set cv = mv
    set i = 1
    loop
        exitwhen i > l
        call UnitAddAbility( u, a )
        call SetUnitAbilityLevel( u, a, (2 + s) )
        call UnitRemoveAbility( u, a )
        set i = i + 1
    endloop
    set i = 1
    loop
        exitwhen i > cv
        call UnitAddAbility( u , a )
        call SetUnitAbilityLevel( u, a, (1 + s) )
        call UnitRemoveAbility( u, a )
        set i = i + 1
    endloop
    set u = null
endfunction

then trigger where u want use

JASS:
function Trig_mp_debuff_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == *debuffer ability id*
endfunction

function Trig_mp_debuff_Actions takes nothing returns nothing
local boolean exit = false
local unit u = GetTriggerUnit()
local unit up = null
local integer mp 
local integer mpdur = 10
local integer pnr 
local integer array mps
local player p 
local player p1 = GetTriggerPlayer()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local group gr1 = CreateGroup()
local group gr2 = CreateGroup()
local integer cv 
//if u want change the duration then change the mpdur to any number what u want
// change the 600 if u want shorter range
call GroupEnumUnitsInRange(gr1,x,y,600.00,null)
loop
   set up = FirstOfGroup(gr1)
   exitwhen up==null
   call GroupRemoveUnit(gr1, up) 
//delete the ==false if u want debuff the enemy and not  ur ally
   if (IsUnitEnemy(up, p1)==false) and (GetWidgetLife(up) > 0) then
       set cv = GetUnitUserData(up)
       set p = GetOwningPlayer(up)
       call GroupAddUnit(gr2, up)
       set mp = R2I ( GetUnitState(up, ConvertUnitState(2)) - 100.00)
       set mps[cv] = mp
        //if true then its mp, if false then mana modification
       call AddHPMP(false, mp*-1, up)
       call DisplayTextToPlayer( p,0,0, "|cffffff77" + GetUnitName(up) + "|r got mp debuff (-" + R2S (mp) + " )" )
   endif  
endloop
call TriggerSleepAction(mpdur)
loop
   set up = FirstOfGroup(gr2)
   exitwhen up==null
    set p = GetOwningPlayer(up)
    call GroupRemoveUnit(gr2, up) 
	set cv = GetUnitUserData(up)
    set mp = mps[cv]
    if (mp>0) then
      if (GetUnitState(up, ConvertUnitState(0)) > 0) then
       set mps[cv] = 0
       call AddHPMP(false, mp, up)
       call DisplayTextToPlayer( p,0,0, "|cffffff77" + GetUnitName(up) + "|r regained the lost mp (+" + R2S (mp) +" )" )
      endif
    endif  
endloop
call DestroyGroup(gr1)
call DestroyGroup(gr2)
set gr1 = null
set gr2 = null
set u = null
set p = null
set p1 = null
endfunction

//===========================================================================
function InitTrig_MP_Debuff takes nothing returns nothing
    set gg_trg_MP_Debuff = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_MP_Debuff, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_MP_Debuff, Condition( function Trig_mp_debuff_Conditions ) )
    call TriggerAddAction( gg_trg_MP_Debuff, function Trig_mp_debuff_Actions )
endfunction
 

Attachments

  • 1.jpg
    1.jpg
    144.3 KB · Views: 109
u could use a harder methode what modify the max mana so unit cant use potion or trick out

At map init, pls check the screenshot for makeing 2 ability but if u need only mana reduction then only 1 (ability based on item ability gain max mp)
  • Abilities2[1] = *your hp ability*
  • Abilities2[2] = *your mp ability*
To header
JASS:
//add/decrease hp or mp
function AddHPMP takes boolean HP, integer v, unit u returns nothing
    local integer a
    local integer s
    local integer i
    local integer l
    local integer cv
    local integer mv

    if HP then
        set a = udg_Abilities2[1]
    else
        set a = udg_Abilities2[2]
    endif

    if (v >= 0) then
        set s = 1
        set cv = v
    else
        set s = 5
        set cv = v * - 1
    endif
    set mv = cv - (cv / 1000) * 1000
    set l = cv / 1000
    set i = 1
    loop
        exitwhen i > l
        call UnitAddAbility( u, a )
        call SetUnitAbilityLevel( u, a, (4 + s) )
        call UnitRemoveAbility( u, a )
        set i = i + 1
    endloop
    set cv = mv
    set mv = cv - (cv / 100) * 100
    set l = cv / 100
    set cv = mv
    set i = 1
    loop
        exitwhen i > l
        call UnitAddAbility( u, a )
        call SetUnitAbilityLevel( u, a, (3 + s) )
        call UnitRemoveAbility( u, a )
        set i = i + 1
    endloop
    set mv = cv - (cv / 10) * 10
    set l = cv / 10
    set cv = mv
    set i = 1
    loop
        exitwhen i > l
        call UnitAddAbility( u, a )
        call SetUnitAbilityLevel( u, a, (2 + s) )
        call UnitRemoveAbility( u, a )
        set i = i + 1
    endloop
    set i = 1
    loop
        exitwhen i > cv
        call UnitAddAbility( u , a )
        call SetUnitAbilityLevel( u, a, (1 + s) )
        call UnitRemoveAbility( u, a )
        set i = i + 1
    endloop
    set u = null
endfunction

then trigger where u want use

JASS:
function Trig_mp_debuff_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == *debuffer ability id*
endfunction

function Trig_mp_debuff_Actions takes nothing returns nothing
local boolean exit = false
local unit u = GetTriggerUnit()
local unit up = null
local integer mp 
local integer mpdur = 10
local integer pnr 
local integer array mps
local player p 
local player p1 = GetTriggerPlayer()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local group gr1 = CreateGroup()
local group gr2 = CreateGroup()
local integer cv 
//if u want change the duration then change the mpdur to any number what u want
// change the 600 if u want shorter range
call GroupEnumUnitsInRange(gr1,x,y,600.00,null)
loop
   set up = FirstOfGroup(gr1)
   exitwhen up==null
   call GroupRemoveUnit(gr1, up) 
//delete the ==false if u want debuff the enemy and not  ur ally
   if (IsUnitEnemy(up, p1)==false) and (GetWidgetLife(up) > 0) then
       set cv = GetUnitUserData(up)
       set p = GetOwningPlayer(up)
       call GroupAddUnit(gr2, up)
       set mp = R2I ( GetUnitState(up, ConvertUnitState(2)) - 100.00)
       set mps[cv] = mp
        //if true then its mp, if false then mana modification
       call AddHPMP(false, mp*-1, up)
       call DisplayTextToPlayer( p,0,0, "|cffffff77" + GetUnitName(up) + "|r got mp debuff (-" + R2S (mp) + " )" )
   endif  
endloop
call TriggerSleepAction(mpdur)
loop
   set up = FirstOfGroup(gr2)
   exitwhen up==null
    set p = GetOwningPlayer(up)
    call GroupRemoveUnit(gr2, up) 
	set cv = GetUnitUserData(up)
    set mp = mps[cv]
    if (mp>0) then
      if (GetUnitState(up, ConvertUnitState(0)) > 0) then
       set mps[cv] = 0
       call AddHPMP(false, mp, up)
       call DisplayTextToPlayer( p,0,0, "|cffffff77" + GetUnitName(up) + "|r regained the lost mp (+" + R2S (mp) +" )" )
      endif
    endif  
endloop
call DestroyGroup(gr1)
call DestroyGroup(gr2)
set gr1 = null
set gr2 = null
set u = null
set p = null
set p1 = null
endfunction

//===========================================================================
function InitTrig_MP_Debuff takes nothing returns nothing
    set gg_trg_MP_Debuff = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_MP_Debuff, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_MP_Debuff, Condition( function Trig_mp_debuff_Conditions ) )
    call TriggerAddAction( gg_trg_MP_Debuff, function Trig_mp_debuff_Actions )
endfunction

Wow man, this was deep, really really deep. So basicly u set real = hero mana and loop MANA ITEM GAIN (with minus) and give it to the player uptill it has exactly 100 (with +1 +10 +100 +1000, -1, -10 -100 -1000)
Did I get it?
That was really really deep, seryesly,
but it has 3 bugs: u cant return the player mana as soon as the spell dispelled or finished, and u cant track how much mana cap u removed from the hero. the final bug is that adding too many abilities causes brief lag that can become big, when spammed.
It was really really deep and I couldnt think about it , but I found "easier" way to do it, since my map is complete, do you wanna see it? :D. :ogre_haosis:
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Wow man, this was deep, really really deep. So basicly u set real = hero mana and loop MANA ITEM GAIN (with minus) and give it to the player uptill it has exactly 100 (with +1 +10 +100 +1000, -1, -10 -100 -1000)
Did I get it?
That was really really deep, seryesly,
but it has 3 bugs: u cant return the player mana as soon as the spell dispelled or finished, and u cant track how much mana cap u removed from the hero. the final bug is that adding too many abilities causes brief lag that can become big, when spammed.
It was really really deep and I couldnt think about it , but I found "easier" way to do it, since my map is complete, do you wanna see it? :D. :ogre_haosis:

u tryed or just talk?

1. not deep coz most of jass u must copy only, 1st to header 2nd make a trigger, convert to custom text and past this instead that, u must do only 1-2 ability (depend if u need hp too) and put ur ability id where i wrote

2.every mana store to array and its give back exactly how much was removed, also for this need the unit indexer trigger from gui damage engine http://www.hiveworkshop.com/forums/spells-569/gui-damage-engine-201016/
displelled thing is right, this isnt dispell able, but have another methode, if u save to harshtable instead local array then u can make a trigger where the even unit begin cast and casted ability=purge etc and with load data from harshtable u can give back the removed mp and every harshtable value where the buff was stored to 0.
(u can save to harshtable like this: 1st key is debuff number lets say 8, second is unit custom value) - u can see the example in my orpg template where hp buff was made like this just there still isnt buffable.
(noticed at debuff trigger u dont debuff the units if there debuff value not 0 in harshtable, so u cant debuff the unit 2x before his buff expired and with this u ignore the only problem with harshtable methode)

anyway what i removed was stored to here
JASS:
set mps[cv] = mp
its mean every unit mana difference is stred to a array where the index is the unit custom value what is unique to every unit if u use index what really easy to implentate mbecause just copy/paste :p

3. huge lagg? not even noticedable since its lagg only 1st time the custom ability but u can preload all ability at map init=>dont lagg even u add 30 to a unit

try add more unit on my orpg template near hero and test it urself if u think its alggy
 
- Never use local groups then destroy, use global groups or bj_lastCreatedGroup...
- This if ???==false, should be this not ???...
- The loops that adds the ability lags, set preload to it...
- Don't use TriggerSleepAction, use a timer that expired instead...
- No need for a unit indexer with complex code, hastahbles will just do fine...

I'll come up with something simple...
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
- Never use local groups then destroy, use global groups or bj_lastCreatedGroup...
- This if ???==false, should be this not ???...
- The loops that adds the ability lags, set preload to it...
- Don't use TriggerSleepAction, use a timer that expired instead...
- No need for a unit indexer with complex code, hastahbles will just do fine...

I'll come up with something simple...

- right
- i said need preload but i dont wrote preload trigger coz everybody can add a ability to unit and remove it.
- i wrote not the best but somehow i think its more simple to somebody who dont want complicate it instead harshtable and timers where need much more thing
- easier pase a trigger what need everywhere mostly than makeing harshtable and everytime save load data if we need something simple thing

what i wrote easy in that point when u implentate, not the best but usefull, also that functions (add hp/mp, indexer) could use in more palce like add self max hp/mp buff ability or max hp debuffer ability etc, and indexer i think its a standard sincemostly most of map use dds
 
@shadow
its really not hard to do it via Hashtable, besides if you use custom value of
units, then UnitIndexer needs to be imported which is fast but not needed...

  • StaticMana
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunder Clap
    • Actions
      • -------- too lazy to Filter the unit and remove the location :P... --------
      • Unit Group - Pick every unit in (Units within 512.00 of (Position of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • Custom script: set udg_ID = GetHandleId(GetEnumUnit())
          • Set Index = (Index + 1)
          • Hashtable - Save 10.00 as 100 of ID in Hash
          • Hashtable - Save 100.00 as 101 of ID in Hash
          • Unit Group - Add (Picked unit) to Grp
      • Trigger - Turn on Loop <gen>
  • StaticManaLoop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Grp and do (Actions)
        • Loop - Actions
          • Set Target = (Picked unit)
          • Custom script: set udg_ID = GetHandleId(GetEnumUnit())
          • Set Duration = (Load 100 of ID from Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target is alive) Equal to True
              • Duration Greater than 0.00
            • Then - Actions
              • Hashtable - Save (Duration - 0.10) as 100 of ID in Hash
              • Set Mana = (Load 101 of ID from Hash)
              • -------- floating text is really not needed --------
              • Floating Text - Create floating text that reads (String(Duration)) above Target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change the lifespan of (Last created floating text) to 0.09 seconds
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Mana of Target) Greater than Mana
                • Then - Actions
                  • Unit - Set mana of Target to Mana
                • Else - Actions
            • Else - Actions
              • Unit Group - Remove Target from Grp
              • Set Index = (Index - 1)
              • -------- flush also is OK --------
              • Custom script: call RemoveSavedReal(udg_Hash, udg_ID, 100)
              • Custom script: call RemoveSavedReal(udg_Hash, udg_ID, 101)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
@shadow
its really not hard to do it via Hashtable, besides if you use custom value of
units, then UnitIndexer needs to be imported which is fast but not needed...

  • StaticMana
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunder Clap
    • Actions
      • -------- too lazy to Filter the unit and remove the location :P... --------
      • Unit Group - Pick every unit in (Units within 512.00 of (Position of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • Custom script: set udg_ID = GetHandleId(GetEnumUnit())
          • Set Index = (Index + 1)
          • Hashtable - Save 10.00 as 100 of ID in Hash
          • Hashtable - Save 100.00 as 101 of ID in Hash
          • Unit Group - Add (Picked unit) to Grp
      • Trigger - Turn on Loop <gen>
  • StaticManaLoop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Grp and do (Actions)
        • Loop - Actions
          • Set Target = (Picked unit)
          • Custom script: set udg_ID = GetHandleId(GetEnumUnit())
          • Set Duration = (Load 100 of ID from Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target is alive) Equal to True
              • Duration Greater than 0.00
            • Then - Actions
              • Hashtable - Save (Duration - 0.10) as 100 of ID in Hash
              • Set Mana = (Load 101 of ID from Hash)
              • -------- floating text is really not needed --------
              • Floating Text - Create floating text that reads (String(Duration)) above Target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change the lifespan of (Last created floating text) to 0.09 seconds
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Mana of Target) Greater than Mana
                • Then - Actions
                  • Unit - Set mana of Target to Mana
                • Else - Actions
            • Else - Actions
              • Unit Group - Remove Target from Grp
              • Set Index = (Index - 1)
              • -------- flush also is OK --------
              • Custom script: call RemoveSavedReal(udg_Hash, udg_ID, 100)
              • Custom script: call RemoveSavedReal(udg_Hash, udg_ID, 101)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions

oh i thought u do in jass with timer there.

ok in gui your is shorter :p

with harshtable my problem is: i got 96 ability on my map, so lets make 96 harshtable or 200+ global variable? :p
i prefer triggersleep in that view point, y less accurated, yea could affter the lagg but still when i use 96 ability i skip alot harshtable useage :p
 
  • T1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunder Clap
    • Actions
      • Custom script: local real mana
      • Wait 0.00 seconds
      • Set Counter = (Counter + 1)
      • Trigger - Turn on T2 <gen>
      • Custom script: set mana = GetUnitState(GetTriggerUnit(), UNIT_STATE_MANA)
      • Unit Group - Add (Triggering unit) to G
      • Wait 10.00 seconds
      • Set Counter = (Counter - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Counter Equal to 0
        • Then - Actions
          • Trigger - Turn off T2 <gen>
        • Else - Actions
      • Unit Group - Remove (Triggering unit) from G
      • Custom script: call SetUnitState(GetTriggerUnit(), UNIT_STATE_MANA, mana)
  • T2
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in G and do (Actions)
        • Loop - Actions
          • Unit - Set mana of (Picked unit) to 100.00
JASS:
function T1_run takes nothing returns nothing
    local real mana
    if GetSpellAbilityId() == 'AHtc' then
        call TriggerSleepAction( 0.00 )
        set udg_Counter = udg_Counter + 1
        call EnableTrigger( gg_trg_T2_jass )
        set mana = GetUnitState(GetTriggerUnit(), UNIT_STATE_MANA)
        call GroupAddUnit(udg_G, GetTriggerUnit())
        call TriggerSleepAction( 10.00 )
        set udg_Counter = udg_Counter - 1
        if udg_Counter == 0 then
            call DisableTrigger( gg_trg_T2_jass )
        endif
        call GroupRemoveUnit(udg_G, GetTriggerUnit())
        call SetUnitState(GetTriggerUnit(), UNIT_STATE_MANA, mana)
    endif
endfunction

function InitTrig_T1_jass takes nothing returns nothing
    local trigger T = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( T, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( T, function T1_run )
    set T = null
endfunction
JASS:
function T2_doLoop takes nothing returns nothing
    call SetUnitState(GetEnumUnit(), UNIT_STATE_MANA, 100.)
endfunction

function T2_run takes nothing returns nothing
    call ForGroup( udg_G, function T2_doLoop )
endfunction

function InitTrig_T2_jass takes nothing returns nothing
    set gg_trg_T2_jass = CreateTrigger()
    call TriggerRegisterTimerEvent(gg_trg_T2_jass, 0.03, true)
    call TriggerAddAction( gg_trg_T2_jass, function T2_run )
endfunction
JASS:
struct Spell extends array

    private static integer COUNTER       = 0
    private static integer ABILITY_CODE  = 'AHtc'
    private static real DURATION         = 10.
    private static real MANA             = 100.
    private static trigger T             = CreateTrigger()
    private static group G               = CreateGroup()

    private static method setMana takes nothing returns nothing
        call SetUnitState(GetEnumUnit(), UNIT_STATE_MANA, MANA)
    endmethod

    private static method doLoop takes nothing returns nothing
        call ForGroup( G, function thistype.setMana )
    endmethod

    private static method run takes nothing returns nothing
        local real mana
        if GetSpellAbilityId() == ABILITY_CODE then
            call TriggerSleepAction(0.00)
            set COUNTER = COUNTER + 1
            call EnableTrigger(T)
            set mana = GetUnitState(GetTriggerUnit(), UNIT_STATE_MANA)
            call GroupAddUnit(G, GetTriggerUnit())
            call TriggerSleepAction(DURATION)
            set COUNTER = COUNTER - 1
            if COUNTER == 0 then
                call DisableTrigger(T)
            endif
            call GroupRemoveUnit(G, GetTriggerUnit())
            call SetUnitState(GetTriggerUnit(), UNIT_STATE_MANA, mana)
        endif
    endmethod

    private static method onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerRegisterTimerEvent(T, 0.03, true)
        call TriggerAddAction( t, function thistype.run )
        call TriggerAddAction( T, function thistype.doLoop )
        set t = null
    endmethod

endstruct

Few tricks used:
- Wait 0.00 seconds or TriggerSleepAction(0.00) will delay actions long enough so we can store mana without spell manacost (if hero has 500 mana and spell cost 100 mana, instead of 500 we will save 400 mana).
- we use local real in GUI to save different mana value for each different unit (MUI).
- In jass we use for group instead FirstOfGroup to easily avoid indexing and creating more groups.
- We use Wait 10. or TSA(10.) because we don't need accurate timer here.
 

Attachments

  • x.w3x
    17.7 KB · Views: 87
Level 14
Joined
Apr 20, 2009
Messages
1,543
Also this:

JASS:
function TriggerRegisterAnyUnitEventBJ takes trigger trig, playerunitevent whichEvent returns nothing
    local integer index

    set index = 0
    loop
        call TriggerRegisterPlayerUnitEvent(trig, Player(index), whichEvent, null)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
endfunction

readability or 1 less function call, you decide :p
 
This will force as to use 2 groups. We will just complicate things with it.
Now why should it use 2 groups?...
JASS:
private static method doLoop takes nothing returns nothing
   local unit u    
   call ForGroup(G, null)
   loop
      set u = FirstOfGroup(G)
      exitwhen u==null
      if GetUnitState(u, UNIT_STATE_MANA) > MANA then
         call SetUnitState(u, UNIT_STATE_MANA, MANA)       
      endif
      call GroupRemoveUnit(G, u)
   endloop
endmethod

TriggerRegisterAnyUnitEventBJ is just fine
 
Sorry I don't understand.
Also this:
call ForGroup(G, null)

it enumerates the group within the function itself instead of calling another
function and use GetEnumUnit()...this way we can safely use locals,
coz it's in the same function, and it's faster than calling another function as I
said earlier in post #17...
 
Level 37
Joined
Mar 6, 2006
Messages
9,240

  • MaxManaSetup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set MMHT = (Last created hashtable)
      • For each (Integer A) from 2 to 13, do (Actions)
        • Loop - Actions
          • Set MMVALUES[(Integer A)] = (Integer((Power(2.00, (Real(((Integer A) - 2)))))))
      • Set p = (Center of (Playable map area))
      • Unit - Create 1 Footman for Neutral Extra at p facing Default building facing degrees
      • Unit - Add Max Mana Gain to (Last created unit)
      • Unit - Add Max Mana Lose to (Last created unit)
      • Unit - Remove (Last created unit) from the game
      • Custom script: call RemoveLocation(udg_p)
  • MaxManaSpell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flame Strike
    • Actions
      • Set p = (Target point of ability being cast)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 300.00 of p) and do (Actions)
        • Loop - Actions
          • Set u = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (u is A structure) Equal to False
              • (u is alive) Equal to True
              • (u belongs to an enemy of (Owner of (Triggering unit))) Equal to True
            • Then - Actions
              • Set b = True
              • Set i = ((Integer((Max mana of u))) - 100)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • i Greater than 0
                • Then - Actions
                  • Custom script: set udg_id = GetHandleId(udg_u)
                  • Hashtable - Save 30 as 0 of id in MMHT
                  • Hashtable - Save i as 1 of id in MMHT
                  • Unit Group - Add u to MMGRP
                  • Trigger - Turn on MaxManaLoop <gen>
                  • Trigger - Run SetMaxMana <gen> (ignoring conditions)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • i Equal to 0
                    • Then - Actions
                      • Custom script: set udg_id = GetHandleId(udg_u)
                      • Hashtable - Save 30 as 0 of id in MMHT
                    • Else - Actions
            • Else - Actions
      • Custom script: call RemoveLocation(udg_p)
  • MaxManaLoop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MMGRP and do (Actions)
        • Loop - Actions
          • Set u = (Picked unit)
          • Custom script: set udg_id = GetHandleId(udg_u)
          • Set i = ((Load 0 of id from MMHT) - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (u is alive) Equal to True
              • i Greater than 0
            • Then - Actions
              • Hashtable - Save i as 0 of id in MMHT
            • Else - Actions
              • Set b = False
              • Set i = (Load 1 of id from MMHT)
              • Trigger - Run SetMaxMana <gen> (ignoring conditions)
              • Unit Group - Remove u from MMGRP
              • Hashtable - Clear all child hashtables of child id in MMHT
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (MMGRP is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
  • SetMaxMana
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • b Equal to True
        • Then - Actions
          • For each (Integer A) from 2 to 13, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • i Greater than or equal to MMVALUES[(15 - (Integer A))]
                • Then - Actions
                  • Unit - Add Max Mana Lose to u
                  • Unit - Set level of Max Mana Lose for u to (15 - (Integer A))
                  • Unit - Remove Max Mana Lose from u
                  • Set i = (i - MMVALUES[(15 - (Integer A))])
                • Else - Actions
        • Else - Actions
          • For each (Integer A) from 2 to 13, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • i Greater than or equal to MMVALUES[(15 - (Integer A))]
                • Then - Actions
                  • Unit - Add Max Mana Gain to u
                  • Unit - Set level of Max Mana Gain for u to (15 - (Integer A))
                  • Unit - Remove Max Mana Gain from u
                  • Set i = (i - MMVALUES[(15 - (Integer A))])
                • Else - Actions


http://www.hiveworkshop.com/forums/pastebin.php?id=fhf3jj

It could be optimized a bit to be more efficient and configurable. But it works, it limits the max mana to 100.
 
u tryed or just talk?

1. not deep coz most of jass u must copy only, 1st to header 2nd make a trigger, convert to custom text and past this instead that, u must do only 1-2 ability (depend if u need hp too) and put ur ability id where i wrote

2.every mana store to array and its give back exactly how much was removed, also for this need the unit indexer trigger from gui damage engine http://www.hiveworkshop.com/forums/spells-569/gui-damage-engine-201016/
displelled thing is right, this isnt dispell able, but have another methode, if u save to harshtable instead local array then u can make a trigger where the even unit begin cast and casted ability=purge etc and with load data from harshtable u can give back the removed mp and every harshtable value where the buff was stored to 0.
(u can save to harshtable like this: 1st key is debuff number lets say 8, second is unit custom value) - u can see the example in my orpg template where hp buff was made like this just there still isnt buffable.
(noticed at debuff trigger u dont debuff the units if there debuff value not 0 in harshtable, so u cant debuff the unit 2x before his buff expired and with this u ignore the only problem with harshtable methode)

anyway what i removed was stored to here
JASS:
set mps[cv] = mp
its mean every unit mana difference is stred to a array where the index is the unit custom value what is unique to every unit if u use index what really easy to implentate mbecause just copy/paste :p

3. huge lagg? not even noticedable since its lagg only 1st time the custom ability but u can preload all ability at map init=>dont lagg even u add 30 to a unit

try add more unit on my orpg template near hero and test it urself if u think its alggy

3. huge lagg? not even noticedable since its lagg only 1st time the custom ability but u can preload all ability at map init=>dont lagg even u add 30 to a unit

I really not understand what you wrote about since I am dumb when it come to using jazz, but I have no words to describe how usefull this information you just said for me. Thanks.
Maker: exelent work, I am also dumb when it come to hashtables XD but this is so impressive that you should post it on abilities sector
XD
 
Status
Not open for further replies.
Top