[Spell]: An AoE mana-suck, need trigger help.

Expelliarmus

Where to change the sig?
Reaction score
48
JASS:
//function Mana Bomb takes nothing returns integer // functions can not have spaces
function Mana_Bomb takes nothing returns integer 
    //return 'A093:AHtc' 
    return 'AHtc' // Raw Codes are 4 characters
endfunction

function AoE takes nothing returns integer
    return 900 
endfunction

function spellevel takes integer lvl returns integer 
    return lvl * -200 
endfunction

function UnitFilter takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0 and IsUnitAlly(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit()))
endfunction

function Absorb takes nothing returns integer
    local integer level
    set level = GetUnitAbilityLevel(GetTriggerUnit(),Mana_Bomb()) // Mana_Bomb was SpellID
    call SetUnitState(GetEnumUnit(),UNIT_STATE_MANA, spellevel(level))
    return spellevel(level)
endfunction

function Trig_Mana_Drain_Actions takes nothing returns nothing
    local unit caster
    local group g
    set g = CreateGroup()
    set caster = GetTriggerUnit()
    call GroupEnumUnitsInRange(g,GetUnitX(caster),GetUnitY(caster), AoE(), Condition(function UnitFilter))
    call ForGroup(g, function Absorb)
    call SetUnitState(caster,UNIT_STATE_MANA, Absorb()*-1)
    call DestroyGroup(g)
    set caster = null
    set g = null
endfunction

function Trig_Mana_Drain_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Mana_Bomb()
endfunction

//===========================================================================
function InitTrig_Mana_Drain takes nothing returns nothing
    set gg_trg_Mana_Drain = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Mana_Drain, function Trig_Mana_Drain_Actions )
    call TriggerAddCondition(gg_trg_Mana_Drain, Condition(function Trig_Mana_Drain_Conditions))
endfunction

- No event
- SetUnitState problem?
 

saw792

Is known to say things. That is all.
Reaction score
280

BarzahdX

Active Member
Reaction score
18
Alright, I added that.. Still no mana draining effect.. I'm not concerned about it being asborbed to him yet, because it should only be absorbing in the first place, if he's taking any.

I really appreciate your consistency on this matter.
 

BarzahdX

Active Member
Reaction score
18
Do you have more than a hunch to solve it? Can you tell me where the flaw is? What should I change, where, and with what?

No real rush, as to theres no deadline when this ability needs to be finished. :)
 

BarzahdX

Active Member
Reaction score
18
Wow, I've never had to wait this long before--not complaining, just caught me off guard.

Any ideas yet?

........ In other words--bump.
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
well its GUI but i think it will work:
Code:
Untitled Trigger 001
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to AoESiphonMana
    Actions
        Set TempPoint = (Position of (Triggering unit))
        Set TempGroup = (Units within 900.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)))
        Unit Group - Pick every unit in TempGroup and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Mana of (Picked unit)) Less than or equal to (200.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))
                    Then - Actions
                        Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + (Mana of (Picked unit)))
                    Else - Actions
                        Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + (200.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
                Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - (200.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
        Custom script: call RemoveLocation (udg_TempPoint)
        Custom script: call DestroyGroup (udg_TempGroup)
 

BarzahdX

Active Member
Reaction score
18
I don't doubt your prowess, and I'll certainly use this code if you can assure me this: Will it absorb mana based on how many enemies there are? I don't want it just to be an AoE mana burn, and a mana pot for the caster, with a set number--I need it to vary. If we can't get it made, I'll think of a different ability, it's not a huge deal.
 

Marsmallos

Member
Reaction score
17
You mean that the ability will drain an equal amount of mana from every unit in range, and then give it to the hero, but maximum total mana drained from everyone must not exceed 200 mana?
like for example, two units are in range when the ability is cast, 100 mana is drained from each and given to the hero, next time when the ability is cast, four enemies are in range, 50 mana are drained from each and given to the hero and so on?
 

BarzahdX

Active Member
Reaction score
18
You mean that the ability will drain an equal amount of mana from every unit in range, and then give it to the hero, but maximum total mana drained from everyone must not exceed 200 mana?
like for example, two units are in range when the ability is cast, 100 mana is drained from each and given to the hero, next time when the ability is cast, four enemies are in range, 50 mana are drained from each and given to the hero and so on?

No. Perhaps an example would be better, I've never been good at explaining things.
You run up to two enemies, your Mana Bomb is level one(it drains 200 mana from each unit). You use Mana Bomb, it takes away 200 mana from each of the units hit, and then the caster gains 400(200 from each unit) mana.

You run up to 5 enemies, your Mana Bomb is level one. You use Mana Bomb, it takes away 200 mana from each of the units hit, and then the caster gains 1000(200 from each unit) mana.

You run up to 10 enemies, your Mana Bomb is level 3(it drains 600 mana from each unit). You use Mana Bomb, it takes away 600 mana from each of the units hit. Then the caster gains 6,000(600 from each unit hit[10 units]) mana.

You run up to 0 enemies. Your Mana Bomb is level 2(level deosn't really matter here). You use Mana Bomb, there are no units around, so no one had their mana drained. The caster gains 0 mana because no mana was burned.

Hope that explains it well enough.
 

Marsmallos

Member
Reaction score
17
Then would this work? (writing from memory as usual, since I dont got World Edit on this computer)

Code:
Events
A unit starts the effect of an ability
Conditions
ability being cast equal to AoE mana drain
Actions
Set Caster_pos = Position of (casting unit)
set Manasuck_targets = units in 900 range of Caster_pos matching (matching unit belongs to an enemy of (owner of triggering unit)
Pick every unit in Manasuck_targets and do Actions
   loop (actions)
    If conditions then actions else actions
      if
         Mana of picked unit Greater than or equal to (200x(Real(Level of Ability being cast for Triggering unit))      [COLOR="Red"](check if the target units have enough mana to drain)[/COLOR]
      then
         set mana of picked unit to (mana of picked unit - (200x(Real(Level of Ability being cast for Triggering unit))    [COLOR="Red"] (drain their mana)[/COLOR]
         set mana of Triggering unit to (mana of Triggering unit + (200x(Real(Level of Ability being cast for Triggering unit))     [COLOR="Red"](give mana to the caster)[/COLOR]
      else


custom script: CLEAN UP ZE LEAKS

Hope this helped ;)
 

BarzahdX

Active Member
Reaction score
18
To Accname: I haven't tried it yet, I was just making sure it did what I wanted it to do--was asking if you could assure me that.

To Marsmallos: No, that wouldn't work, because it's a static mana gain--the burning part is fine, I just want the mana gained, absorbed, to vary based on how much mana was drained total.
 

Marsmallos

Member
Reaction score
17
ooooooh I see I think I hope! I was actually considering it when writing the previous trigger...

Code:
Events
A unit starts the effect of an ability
Conditions
ability being cast equal to AoE mana drain
Actions
Set Caster_pos = Position of (casting unit)
set Manasuck_targets = units in 900 range of Caster_pos matching (matching unit belongs to an enemy of (owner of triggering unit)
Pick every unit in Manasuck_targets and do Actions
   loop (actions)
    [COLOR="Blue"]set [COLOR="Blue"]ManaRealVariable[/COLOR] = mana of picked unit[/COLOR]
     If conditions then actions else actions
      if
         Mana of picked unit Greater than or equal to (200x(Real(Level of Ability being cast for Triggering unit))      (check if the target units have enough mana to drain)
      then
         set mana of picked unit to (mana of picked unit - (200x(Real(Level of Ability being cast for Triggering unit))     (drain their mana)
         set mana of Triggering unit to (mana of Triggering unit + (200x(Real(Level of Ability being cast for Triggering unit))     (give mana to the caster)
      else
         [COLOR="Blue"]set mana of picked unit to 0
         set mana of Triggering unit to (mana of Triggering unit + ManaRealVariable)[/COLOR]

custom script: CLEAN UP ZE LEAKS

Ex at level 1

If the picked units mana is greater than 200 then 200 mana will be subtracted and 200 mana will be added to the caster
else, if the picked units mana is less than 200, for example 63, its mana will be set to 0 and 63 mana will be added to the archon, through the ManaRealVariable that is set in the beginning of the loop.

I am verry tired now so I dont explain very well and maybe I misunderstood you once again but I hope this was what you was looking for :)
 

BarzahdX

Active Member
Reaction score
18
That's very close! Now as it says it gives the caster 200 mana.. Is that for each unit that loses 200(63 also, in your example) mana? Or will he always gain 200 mana, even if there are 50 people within 900 radius? I'm not saying it won't work--I'm asking you if it will.
 

Marsmallos

Member
Reaction score
17
If there are 10 units in range, 9 with above 200 mana and one with 63 mana, then it will (*should*) drain a total of (9x200)+63=1863 mana and give it to the caster.

Since I got a
Pick every unit in Manasuck_targets and do actions
loop actions

it will do the actions listed below for EVERY unit in Manasuck_targets


So unless my tired brain misunderstood you or my make-triggers-without-WorldEdit-skills are failing, then, yes it should work =)
 

BarzahdX

Active Member
Reaction score
18
AWESOME! I greatly anticipate testing this out. :)

Now for the custom scripts, isn't it something like "Custom script: call RemoveLocation (udg_Caster_pos)" for your trigger?
 

BarzahdX

Active Member
Reaction score
18
SUCCESS!!! MUAHAHAHA!! Thank you SOO much everybody! Clearly this was a pretty tricky one.. I'll post the triggers for reference. Spell Id: Mana_Drain. Trigger name: Mana Drain.

GUI trigger that worked.
Code:
Mana Bomb
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Mana_Drain 
    Actions
        Set Archon_Position = (Position of (Casting unit))
        Set Mana_Bomb_Targets = (Units within 900.00 of Archon_Position matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))
        Unit Group - Pick every unit in Mana_Bomb_Targets and do (Actions)
            Loop - Actions
                Set Mana_Bomb_Target_Mana = (Mana of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Mana of (Picked unit)) Greater than or equal to (200.00 x (Real((Level of (Ability being cast) for (Triggering unit)))))
                    Then - Actions
                        Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - (200.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
                        Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + (200.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
                    Else - Actions
                        Unit - Set mana of (Picked unit) to 0.00
                        Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + Mana_Bomb_Target_Mana)
                        Custom script:   call RemoveLocation (udg_Archon_Position)
                        Custom script:   call DestroyGroup (udg_Mana_Bomb_Targets)

JASS that didn't work.
JASS:
function Mana_Drain takes nothing returns integer
    return 'AHtc'
endfunction

function AoE takes nothing returns integer
    return 900 
endfunction

function spellevel takes integer lvl returns integer
    return lvl * -200 
endfunction

function UnitFilter takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0 and IsUnitAlly(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit()))
endfunction

function Absorb takes nothing returns integer
    local integer level
    set level = GetUnitAbilityLevel(GetTriggerUnit(),Mana_Drain())
    call SetUnitState(GetEnumUnit(),UNIT_STATE_MANA, spellevel(level))
    return spellevel(level)
endfunction

function Trig_Mana_Drain_Actions takes nothing returns nothing
    local unit caster
    local group g
    set g = CreateGroup()
    set caster = GetTriggerUnit()
    call GroupEnumUnitsInRange(g,GetUnitX(caster),GetUnitY(caster), AoE(), Condition(function UnitFilter))
    call ForGroup(g, function Absorb)
    call SetUnitState(caster,UNIT_STATE_MANA, Absorb()*-1)
    call DestroyGroup(g)
    set caster = null
    set g = null
endfunction

function Trig_Mana_Drain_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Mana_Drain()
endfunction

//===========================================================================
function InitTrig_Mana_Drain takes nothing returns nothing
    set gg_trg_Mana_Drain = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Mana_Drain, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction( gg_trg_Mana_Drain, function Trig_Mana_Drain_Actions )
    call TriggerAddCondition(gg_trg_Mana_Drain, Condition(function Trig_Mana_Drain_Conditions))
endfunction


GUI Trigger that worked, converted into JASS.
JASS:
function Trig_Mana_Bomb_Jass_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A093' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mana_Bomb_Jass_Func002002003 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Trig_Mana_Bomb_Jass_Func003Func002C takes nothing returns boolean
    if ( not ( GetUnitStateSwap(UNIT_STATE_MANA, GetEnumUnit()) >= ( 200.00 * I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetTriggerUnit())) ) ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mana_Bomb_Jass_Func003A takes nothing returns nothing
    set udg_Mana_Bomb_Target_Mana = GetUnitStateSwap(UNIT_STATE_MANA, GetEnumUnit())
    if ( Trig_Mana_Bomb_Jass_Func003Func002C() ) then
        call SetUnitManaBJ( GetEnumUnit(), ( GetUnitStateSwap(UNIT_STATE_MANA, GetEnumUnit()) - ( 200.00 * I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetTriggerUnit())) ) ) )
        call SetUnitManaBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit()) + ( 200.00 * I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetTriggerUnit())) ) ) )
    else
        call SetUnitManaBJ( GetEnumUnit(), 0.00 )
        call SetUnitManaBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit()) + udg_Mana_Bomb_Target_Mana ) )
        call RemoveLocation (udg_Archon_Position)
        call DestroyGroup (udg_Mana_Bomb_Targets)
    endif
endfunction

function Trig_Mana_Bomb_Jass_Actions takes nothing returns nothing
    set udg_Archon_Position = GetUnitLoc(GetSpellAbilityUnit())
    set udg_Mana_Bomb_Targets = GetUnitsInRangeOfLocMatching(900.00, udg_Archon_Position, Condition(function Trig_Mana_Bomb_Jass_Func002002003))
    call ForGroupBJ( udg_Mana_Bomb_Targets, function Trig_Mana_Bomb_Jass_Func003A )
endfunction

//===========================================================================
function InitTrig_Mana_Bomb_Jass takes nothing returns nothing
    set gg_trg_Mana_Bomb_Jass = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Mana_Bomb_Jass, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Mana_Bomb_Jass, Condition( function Trig_Mana_Bomb_Jass_Conditions ) )
    call TriggerAddAction( gg_trg_Mana_Bomb_Jass, function Trig_Mana_Bomb_Jass_Actions )
endfunction


Perhaps these could be used for reference or something.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top