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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top