A Couple Questions [Systems]

NeuroToxin

New Member
Reaction score
46
Okay, so here's what I have.
JASS:

library Summons
//==========================================================================
//================================SETUP=====================================
//==========================================================================
globals
private ability array SummonAbility[1] = 'AHfs'//The summon ability, *Note, if you want to add more, just copy this line,
//Then just change the [1] to a [2] or a [3] etc. and add 1 number to i, *Note, only add 1 to i when you add another ability.
private unit array Unit_Id[1] = 'e00A'//Same as the "SummonAbility" variable, just copy and paste the line.
private real array NumSummoned[1] = 2//The number of summoned Units of X type.
private integer i = 1//Needed for the loops.
private integer m = i//Needed once again.

endglobals

//===========================================================================
//=============================ENDSETUP======================================
//===========================================================================

private function WhatSpells takes nothing returns boolean
    for
        exitwhen 1 >= i
            if GetSpellAbilityId() == SummonAbility<i> then
                return true
            endif
        set i = i - 1
endfunction

struct
private real x
private real y
private location temploc

private method CreateUnits takes nothing returns nothing
set i = m
local player p = GetOwningPlayer(GetTriggerUnit())
    call WhatSpells()
            set temploc = GetSpellTargetLoc()
            set x = GetLocationX(temploc)
            set y = GetLocationY(temploc)
                for
                    exitwhen 1 &gt;= i
                        for
                            exitwhen 1 &gt;= i
                            CreateUnit(p, Unit_Id, x, y, 270)
                    set i = i - 1
        endmethod
endstruct
//===========================================================================
function InitTrig_Summons_System takes nothing returns nothing
    set gg_trg_Summons_System = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Summons_System, function Trig_Start_Actions )
endfunction
endlibrary
</i>


All its supposed to do, is summon X Units at targeted spot, and im gonna add some graphics. Im gonna add more to it after I can get this much working, but im confused as to how to make it MUI, and if I have to loop through each of the spells in order to check if any of them are the right one? And what do I use as a variable in order to say the ability ID? like 'A006'
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Im gonna add more to it after I can get this much working, but im confused as to how to make it MUI,
If a system accomodates for different players (yours does, ie "GetOwningPlayer(GetTriggerUnit()) instead of using a literal) and has no waits (yours has no waits), then it's pretty much going to be naturally MUI. Non-MUI is usually a result of conflicting variable writing, but if everything in a given instance happens instantaneously, there is no time for a conflict to occur!

and if I have to loop through each of the spells in order to check if any of them are the right one?
You're going to have to check them one way or another; that's one way to do it.

And what do I use as a variable in order to say the ability ID? like 'A006'
Integer.

The rawcodes like 'A006' are actually integers in base-256; the values on each character are their ASCII values. Fortunately, 'A006' is valid notation in Jass; otherwise we would have to use out ugly conversions.

//=====================

Comments:

-What you're trying to do right now with some stuff in the struct/some stuff not in it seems a little weird and clunky.
-There is no "for" loop in Jass. All loops just start with "loop" and end with "endloop". How the loop behaves depends entirely on how you build your exitwhen structure.
-Arrays in Jass always have 8192 elements (ie [ljass]unit array u[2][/ljass] just becomes [ljass]unit array u[/ljass] in the compiled code); you don't need to specify size. One note to make about that, though: IIRC, using the final element is dangerous with saved games.
 

NeuroToxin

New Member
Reaction score
46
How about this?
JASS:
library Summons
globals

private integer array SummonAbility = &#039;AHfs&#039;
private unit array Unit_Id = &#039;e00A&#039;
private real array NumSummoned = 2

endglobals

//==========================================================================
//================================SETUP=====================================
//==========================================================================
globals
set SummonAbility[1] = &#039;AHfs&#039;//The summon ability, *Note, if you want to add more, just copy this line,
//Then just change the [1] to a [2] or a [3] etc. and add 1 number to i, *Note, only add 1 to i when you add another ability.
set Unit_Id[1] = &#039;e00A&#039;//Same as the &quot;SummonAbility&quot; variable, just copy and paste the line.
set NumSummoned[1] = 2//The number of summoned Units of X type.
private integer i = 1//Needed for the loops, when you add another spell, just increase the size of this by one.
private integer m = i//Needed once again.
endglobals

//===========================================================================
//=============================ENDSETUP======================================
//===========================================================================

private function WhatSpells takes nothing returns boolean
    loop
        exitwhen 1 &gt; i
            if GetSpellAbilityId() == SummonAbility<i> then
                return true
        set i = i - 1
    endloop
endfunction

private function CreateUnits takes nothing returns nothing
set i = m
local player p = GetOwningPlayer(GetTriggerUnit())
    call WhatSpells()
            set temploc = GetSpellTargetLoc()
            set x = GetLocationX(temploc)
            set y = GetLocationY(temploc)
            loop
                exitwhen 1 &gt;= i
                    loop
                        exitwhen 1 &gt;= NumSummoned<i>
                            CreateUnit(p, Unit_Id, x, y, 270)
                set i = i - 1
            endloop
        endloop
endfunction

//===========================================================================
function InitTrig_Summons_System takes nothing returns nothing
    set gg_trg_Summons_System = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Summons_System, function Trig_Start_Actions )
endfunction
endlibrary
</i></i>



Edit: When I save it says, "Missing Endblock" but the script written was made by blizzard, and it says line 872...
 

SerraAvenger

Cuz I can
Reaction score
234
No
set
in global blocks!

Also, use indention to make your code easier to read; This will help both you and us to spot errors and make changes.

EDIT: By indenting your code in my head, I could find your error:

JASS:
// random stuff that doesn&#039;t make any sense
            if GetSpellAbilityId() == SummonAbility<i> then
                return true
</i>


needs an endif
 

tooltiperror

Super Moderator
Reaction score
231
You did not end a block (if/loop/function usually) somewhere. Disable all your triggers, then enable half and see if it is in that half, etc. till you figure out where it is. Then search that trigger for a missing endx.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top