Complicated trigger spell help

Smitty

Member
Reaction score
20
I vaguely remember the reason I had trouble installing newgen was because I'm on a mac, although I have to say I never really tried that hard, always worked around it. Just checking, anyone know where I can get me a mac version? Or am I being intolerably stupid? >.<
 

Smitty

Member
Reaction score
20
Yep. Leaves me kinda fuxed. Presumably newgen isn't a requirement to actually use this spell? I've not yet found it to be overly inhibiting, or restricting in what I can and can't do.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
NewGen adds the following:
Libraries
Scopes
Structs
Textmacros
Modules
Methods (functions in structs)

And both the spell and all of it's requirements have a requirement of NewGen (Or at least JassHelper)
 

Smitty

Member
Reaction score
20
So I can't use that :( buggeration, I guess I'll just send you a slice of a cake ;-; thanks for trying anyways.
 

Smitty

Member
Reaction score
20
Sorry to double post, but; what do I need to do to this to allow me to use it without newgen? :s
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
it becomes way more complicated, ill make something that works without it though...
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
You will need a unit indexing system for this to work, one that uses a variable or function to store the units saved, and make sure to edit the settings (first function) and the line: [ljass]set u = whichUnit[this][/ljass] to propperly reference the unit saved in the index (this), if it is a variable, replace [ljass]whichUnit[/ljass] with [ljass]udg_VariableName[/ljass] or if it is a function that takes an integer and returns the unit use something like this: [ljass]set u = FunctionName(this)[/ljass]

Implementation:
  • Create a new trigger named StaticShock
  • Edit -> Convert to custom text
  • Delete whats inside and paste the code there
  • Edit the function: [ljass]SetSettings[/ljass]
  • Create the variables listed below
  • Try to save the map
  • If you got any errors tell me, do not worry the map will have saved, but you wont be able to open it in game until you delete my code or i fix the error, you will be able to open it in the editor though.

You will need the following variables:

Integer array [8190] variable: SS_NEXT
Integer array [8190] variable: SS_PREV
Player array [8190] variable: SS_CASTER
Boolean array [8190] variable: SS_SHOCKED

Integer variable: SS_ABIL_ID
Integer variable: SS_DUMMY_ID
Integer variable: SS_BUFF_ID
Real variable: SS_RADIUS
Real variable: SS_FREQUENCY
Boolean variable: SS_PAUSED
Timer variable: SS_TIMER
String variable: SS_CAST_STRING

JASS:
function SS_SetSettings takes nothing returns nothing
    set udg_SS_ABIL_ID = &#039;A000&#039;  //the id for the ability
    set udg_SS_DUMMY_ID = &#039;hfoo&#039; //dummy unit used to cast the ability to bounce
    set udg_SS_BUFF_ID = &#039;A000&#039;  //the id for the buff that the ability applies
    set udg_SS_CAST_STRING = &quot;&quot;  //put the cast string inside the &quot;&quot;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 = whichUnit[this] //&lt;----- replace whichUnit with the variable holding the units for each index
        if 0 &lt; 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)
                    call UnitApplyTimedLife(bj_lastCreatedUnit, 0, 3)
                    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]
            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 Init_Trig_StaticShock takes nothing returns nothing
    local trigger t = CreateTrigger()
    call SS_SetSettings()
    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


DISCLAIMER: i have not gotten to compile this, will do so when i get home, but it should work without JNGP
 

Smitty

Member
Reaction score
20
You, sir, are a legend of decidedly epic proportions. I may need a small amount of help implementing this, but straight away I shall dispatch to you a cake of the finest quality. Not able to test it yet, but thanks :D
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
kk :) i expect it within 2 weeks :p, there will probably be issues with it at first but ill deal with them when i get home tonight
 

Smitty

Member
Reaction score
20
Yeh, might need you to explain some of that 'unit index variable' stuff. Not able to try it yet, but :D!!
 

Smitty

Member
Reaction score
20
I'm being stupid... How do i even get this into a trigger? XD

No, really, I'm not that bad usually, but for the life of me I can't seem to get this thing integrated :(

EDIT: OK, so I got that far... creating variables and stuff, might need you to explain a small amount regarding the trigger. Can't say I understand... any of it. Giving it a whirl but expect cries for help soon :)

RE-EDIT: Only part I seem to be having a problem with is the 'whichunit' part. When you say 'variable holding the units for each index' I have no idea what you mean :] Turns up 32 compile errors also :p
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
ok the 32 compile errors is actually good, that usually means there is 1 issue with referencing a variable in creation... and you need an indexing system for this to work, i would go with the GUI AIDS indexing system cuz it works for GUI users...

the whichUnit is the way you get which unit it is checking at the moment, whatever unit is [this] when this is an integer variable, so like if your unit is unit number 1, then this = 1, therefore its whichUnit[1] which would be your unit, get it?
 

Smitty

Member
Reaction score
20
Right. No. So what exactly am I replacing in that part? The 'This'?

EDIT: hang on, does that refer to a unit array variable? :s

RE-EDIT: Just realised, unit indexing thingumy needed. Right, I'll grab that and see if this makes more sense :)
 

Smitty

Member
Reaction score
20
Ok, got my hands on AIDS, just working out how to match the two together... I think I want AIDS_IndexUnit, but I can't know because I can't test the map :p Any movement on those compiling errors? And massive thanks for the support, sorry to be a JASS nub :(
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
well before i can do anything you need the indexing system working, make sure u are using the GUI one, not the jass one
after that copy and paste the errors you get once it is...
 

Smitty

Member
Reaction score
20
Got it working, 11 errors. Here goes;

Line 364: Invalid number of arguments
Line 388: Expected a function name
Line 391: Expected 'then'
Line 399: Expected 'endif'
Line 402: Need return value in function
Line 404: Expected end of line
Line 406: Expected a name
Line 407: Expected a name
Line 409: expected a function name
Line 410: Expected a variable name
Line 410: Expected 'endif'

Thanks for all the help so far. Your first piece of cake is on its way. I couldn't find your address though so I sent one to every address. EVERY. ADDRESS.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
ill have time to wrap this up in about an hour and 20 mins
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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