Complicated trigger spell help

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
Fixed.
JASS:
function SS_SetSettings takes nothing returns nothing
    set udg_SS_ABIL_ID = 'A000'  //the id for the ability
    set udg_SS_DUMMY_ID = 'hfoo' //dummy unit used to cast the ability to bounce
    set udg_SS_BUFF_ID = 'A000'  //the id for the buff that the ability applies
    set udg_SS_CAST_STRING = ""  //put the cast string inside the ""s (if you dont know it, search the order string of the base ability)
    set udg_SS_RADIUS = 500      //distance targets can be from the unit
    set udg_SS_FREQUENCY = 0.5   //interval in seconds that it shocks units around it
endfunction

function SS_PERIODIC takes nothing returns nothing
    local integer this = udg_SS_NEXT[0]
    local unit u
    local unit a
    local real x
    local real y
    loop
        exitwhen 0 == this
        set u = udg_GUI_UI_IndexUnit[this] //<----- replace whichUnit with the variable holding the units for each index
        if 0 < GetUnitAbilityLevel(u, udg_SS_BUFF_ID) then
            set x = GetUnitX(u)
            set y = GetUnitY(u)
            call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, udg_SS_RADIUS, null)
            loop
                set a = FirstOfGroup(bj_lastCreatedGroup)
                exitwhen a == null
                if IsUnitAlly(a, GetOwningPlayer(u)) and IsUnitType(a, UNIT_TYPE_HERO) then
                    call CreateUnit(udg_SS_CASTER[this], udg_SS_DUMMY_ID, x, y, 0)
                    call UnitApplyTimedLife(bj_lastCreatedUnit, udg_SS_BUFF_ID, 3.00)
                    call IssueTargetOrder(bj_lastCreatedUnit, udg_SS_CAST_STRING, a)
                endif
                call GroupRemoveUnit(bj_lastCreatedGroup, a)
            endloop
            set this = udg_SS_NEXT[this]
        else
            set this = udg_SS_NEXT[this]
            set udg_SS_SHOCKED[udg_SS_PREV[this]] = false
            set udg_SS_NEXT[udg_SS_PREV[udg_SS_PREV[this]]] = this
            set udg_SS_PREV[this] = udg_SS_PREV[udg_SS_PREV[this]]
            if 0 == udg_SS_NEXT[0] then
                call PauseTimer(udg_SS_TIMER)
                set udg_SS_PAUSED = true
            endif
        endif
    endloop
    set u = null
endfunction

function SS_OnCast takes nothing returns boolean
    local integer this = GetUnitUserData(GetTriggerUnit())
    if GetSpellAbilityId() == udg_SS_ABIL_ID then
        if not udg_SS_PAUSED then
            call TimerStart(udg_SS_TIMER, udg_SS_FREQUENCY, true, function SS_PERIODIC)
            set udg_SS_PAUSED = false
        endif
        if not udg_SS_SHOCKED[this] then
            set udg_SS_NEXT[this] = 0
            set udg_SS_PREV[this] = udg_SS_PREV[0]
            set udg_SS_NEXT[udg_SS_PREV[0]] = this
            set udg_SS_PREV[0] = this
            set udg_SS_SHOCKED[this] = true
        endif
        set udg_SS_CASTER[this] = GetOwningPlayer(GetTriggerUnit())
    endif
    return false
endfunction

function InitTrig_StaticShock takes nothing returns nothing
    local trigger t = CreateTrigger()
    call SS_SetSettings()
    set udg_SS_TIMER = CreateTimer()
    call TriggerAddCondition(t, Filter(function SS_OnCast))
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    set udg_SS_TIMER = CreateTimer()
    call TimerStart(udg_SS_TIMER, udg_SS_FREQUENCY, true, function SS_PERIODIC)
    set t = null
endfunction


also, something nice for you :)

JASS:
// GUI Unit Indexing v1.00
// by G_Freak45
// 
// Requires:
//   
//   -Some GUI knowledge and the attention span to read the "How to"
//
// How to:
//   
//   Implementation:
//     
//     -Create a new trigger named "GUIUnitIndexing"
//     -Copy and paste this code in there, deleting what is inside
//     -Create the unit array variable using an array size of 8191 named "GUI_UI_IndexUnit"
//     -Create the integer array variable using an array size of 8191 named "GUI_UI_Recycle"
//     -Create the integer variable named "GUI_UI_ListSize"
//     -Create the real variable named "GUI_UI_Event_Enter_Map"
//     -Create the real variable named "GUI_UI_Event_Decay"
//     -Create the unit variable named "GUI_UI_Triggering_Unit"
//     
//   Using the system:
//     
//     -The system automatically assigns integers to units that enter the map.
//     -Custom value of a unit is it's assigned integer
//     -GUI_UI_IndexUnit[number] is the unit for the number selected
//     -Replace the event "A unit enters the map" with "Game - GUI_UI_Event_Enter_Map becomes equal to 0.00"
//     -The event "Game - GUI_UI_Event_Decay becomes equal to 0.00" refers to when a unit is about to be
//       deallocated, this is so that you can get any information on the unit before it is removed
//       NOTE: this must only be used with instant triggers, the unit and integer are lost after 0.01 seconds
//     -GUI_UI_Triggering_Unit refers to the unit that just entered the map or is being deallocated for
//       the above events
//
//============================================================================
//=========================== CONFIGURABLE OPTIONS ===========================
//============================================================================

function GUI_UI_Index_Filter takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(), 'Aloc') <= 0
    //replace this^ line with "return true" if you want to index locusted units
endfunction

function GUI_UI_Deallocate_Filter takes unit u returns boolean
    return not IsUnitType(u, UNIT_TYPE_HERO)
    //replace this^ line with "return true" if you want to de-index decaying heroes
endfunction

//============================================================================
//========================= END CONFIGURABLE OPTIONS =========================
//============================================================================

function GUI_UI_Deallocate takes integer this returns boolean
    if GUI_UI_Deallocate_Filter(udg_GUI_UI_IndexUnit[this]) then
        set udg_GUI_UI_Triggering_Unit = udg_GUI_UI_IndexUnit[this]
        set udg_GUI_UI_Event_Decay = 1
        set udg_GUI_UI_Event_Decay = 0
        call TriggerSleepAction(0.01)
        call SetUnitUserData(udg_GUI_UI_IndexUnit[this], 0)
        set udg_GUI_UI_Recycle[this] = udg_GUI_UI_Recycle[0]
        set udg_GUI_UI_Recycle[0] = this
    endif
    return false
endfunction

function GUI_UI_Allocate takes nothing returns boolean
    local integer i = udg_GUI_UI_Recycle[0]
    local unit u = GetTriggerUnit()
    if GetUnitUserData(u) != 0 then
        if 0 == i then
            set udg_GUI_UI_ListSize = udg_GUI_UI_ListSize + 1
            call SetUnitUserData(u, udg_GUI_UI_ListSize)
        else
            call SetUnitUserData(u, udg_GUI_UI_Recycle[0])
            set udg_GUI_UI_Recycle[0] = udg_GUI_UI_Recycle[udg_GUI_UI_Recycle[0]]
        endif
        set udg_GUI_UI_Triggering_Unit = u
        set udg_GUI_UI_Event_Enter_Map = 1
        set udg_GUI_UI_Event_Enter_Map = 0
    endif
    set u = null
    return false
endfunction

function InitTrig_GUIUnitIndexing takes nothing returns nothing
    local trigger t = CreateTrigger()
    local region r = CreateRegion()
    call RegionAddRect(r, GetWorldBounds())
    call TriggerAddCondition(t, Filter(function GUI_UI_Allocate))
    call TriggerRegisterEnterRegion(t, r, Filter(function GUI_UI_Index_Filter))
    set t = CreateTrigger()
    call TriggerAddCondition(t, Filter(function GUI_UI_Deallocate))
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DECAY)
    set t = null
    set r = null
endfunction
 

Smitty

Member
Reaction score
20
Holy. Shit. You, sir, are possibly the finest gentleman this world has known. I mean, we're talking at least 5 top hats at once. Just gonna keep +rep'ing you every time I can from now on. You have this unworthy wretch's eternal thankfulness. And his cake. *excitement* now I can get this spell stuck in there :D
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
today at work i typed up that GUI Unit indexer, its a pretty cool system, it is based off aids but works with gui without using any actual gui triggers (which cause minor leaks) and have events for "a unit enters the map" and "a unit decays" or is "deallocated" basically, it adds integers to units as they enter the map and removes the integers to be recycled as they decay (as long as they arent a hero)

and u dont need to send me cake, but if you do want to send me something im a sucker for coconut cream pie :)

OH

the other thing, those variables for the first system that had SS_SOMETHING_ID need to be those type of variables (something) like, SS_ABIL_ID = ability variable, not integer, thats a difference between jass and gui...
SS_ABIL_ID = ability
SS_BUFF_ID = buff
SS_DUMMY_ID = unit-type
 

Smitty

Member
Reaction score
20
Right, coconut pie it is. Man my postal service guys must hate me by now. Or be really fat. I guess I probably want to have decaying heroes unindexed though, since they're generally not part of anything I need this for? :)

EDIT: Ah, forgot to create variables listed in the spell trigger, what kinds are which? Don't want to get it wrong :p

RE-EDIT: I'm a moron, ignore.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
nooooooo thats almost never true, unless you remove heroes from the game dont de-index them
basically like this you can save stats for each hero like this:

Trigger:
  • Actions
    • Set Critical_Strike_Chance[Custom Value of (Hero_Variable)] = 5.00


and it will keep track of that hero, regardless of how many heroes a player has, its call MUI, multi unit instanceability
 

Smitty

Member
Reaction score
20
Ok, so I got all the triggers happy to run :D but, when I cast the spell nothing happens. Gonna check that I have all the IDs right, but may need a little clarification, since when I press cmd+D in the editor, I get 2 strings of 4 characters separated by a colon next to each ability/unit. Which is the one I want? I thought I had the right one based on the form of the sample IDs you put in :(
 

Smitty

Member
Reaction score
20
Ok, there's something about one of those triggers that just stops my map from working. Happened to the old version :( When I test the map, none of my triggers function. Got a backup (thought this might happen) but yeh, any thoughts? :(
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
hrmmm... didnt happen with me when i tested it... do you have the triggers enabled?
sometimes you can get errors with the map and it will just auto-disable triggers
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
not in the way he needed... it was a debuff that would bounce only when you came near units, it wouldnt be an instant chain, which is what you are refering to
 

Smitty

Member
Reaction score
20
Yeh, both times I've tried to implement this, my maps have just completely stopped working. None of my triggers will run at all, not just those connected with this spell. No chance that some small part requires Newgen? I'll try some more testing, but this trigger definitely seems to be the common factor in both issues :(
 

Smitty

Member
Reaction score
20
Ok, turns out my WE didn't like the size of the arrays. Not done extensive testing yet but I know for sure it doesn't like 8190. I'll try this with small sized array variables. 5000 should be plenty right? If it'll run that. Dunno why this is the case :/
 

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
my maps never allow more than 999 in array size
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
well, do you have less than 1k units at one time, with everyone that possibly can spawning summons etc, cuz if you have under that then it should be fine, otherwise the system will have a shit in your lap

excuse mah language :p
 

Smitty

Member
Reaction score
20
Ok, I got it into the map and my triggers worked! A good start. Only problem is that when I cast the ability on a hero, nothing happens :( It's just the basic ability :x
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
did you adjust the SS_Settings function correctly? you use that as a sorta jass-newbie friendly way to edit variables
all of the variables in there are important to your specific game, you need to set SS_ABIL_ID to 'AbilID' of the ability, which you get from setting view as raw data to true in the object editor and finding your spell, it should replace the name with the id, which you put in apostraphes to signify an integer, ie:
'A000' = First custom ability
'Aloc' = Locust
'hfoo' = Footman
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top