[Simple] Converting GUI to JASS

xoxdragonxox

New Member
Reaction score
1
Solved


Here is my GUI trigger im trying to convert it to jass.
Trigger:
  • ItemS
    • Events
      • Time - Every 90.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 19, do (Actions)
        • Loop - Actions
          • Set Points[3] = (Random point in MAP <gen>)
          • Item - Create Items[(Random integer number between 1 and 9)] at Points[3]
          • Custom script: call RemoveLocation(udg_Points[3])


Here is my attempt

JASS:
function Trig_ItemS_Actions takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i > 19
        set udg_Points[3] = GetRandomLocInRect(gg_rct_MAP)
        call CreateItemLoc( udg_Items[GetRandomInt(1, 9)], udg_Points[3] )
        call RemoveLocation(udg_Points[3])
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_ItemS takes nothing returns nothing
    set gg_trg_ItemS = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_ItemS, 90.00 )
    call TriggerAddAction( gg_trg_ItemS, function Trig_ItemS_Actions )
endfunction


My question is can it be done a better way then what i have above.

and here is my 2nd gui

Trigger:
  • MuzzleFlash
    • Events
      • Unit - A unit owned by Neutral Victim Is attacked
      • Unit - A unit owned by Neutral Extra Is attacked
    • Conditions
      • ((Attacking unit) is A Hero) Equal to True
      • Reloading[(Player number of (Owner of (Attacking unit)))] Equal to 0
    • Actions
      • Special Effect - Create a special effect attached to the weapon of (Attacking unit) using war3mapImported\Konstrukt_ShotgunEffektAttachment.MDX
      • Set MuzzleFlash[(Player number of (Owner of (Attacking unit)))] = (Last created special effect)
      • Wait 1.00 seconds
      • Special Effect - Destroy MuzzleFlash[(Player number of (Owner of (Attacking unit)))]


i have no clue how to convert that lol help.... the reason why i wan tthem in jass is because, of cource better performance and no leaks =]
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
something like this:
JASS:
function Items_actions takes nothing returns nothing
    local integer i = 0
    loop     
        call CreateItem(udg_Items[GetRandomInt(1, 9)], GetRandomReal(udg_MinX, udg_MaxX), GetRandomReal(udg_MinY, udg_MaxY))
        set i = i + 1
        exitwhen i > 19
    endloop
endfunction

//===========================================================================
function InitTrig_Items takes nothing returns nothing
    local timer t = CreateTimer()
    call TimerStart(t, 90., true, function Items_actions)
    set t = null

    set udg_MaxX = GetRectMaxX(gg_rct_MAP)
    set udg_MinX = GetRectMinX(gg_rct_MAP)
    set udg_MaxY = GetRectMaxY(gg_rct_MAP)
    set udg_MinY = GetRectMinY(gg_rct_MAP)
endfunction


btw can you use vJass?

if yes, use Sevion's example (sry bud for taking your idea with timer xd)
 

Sevion

The DIY Ninja
Reaction score
413
The first can be optimized. Instead of a trigger, use a timer:

(Assuming you have NewGen)

JASS:
scope PeriodicItemCreate initializer Init
globals // Why globals? They never change unless you move the rect. Which... you never do, do you? If you do, just reset them <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
    private real maxX = GetRectMaxX(gg_rct_MAP)
    private real minX = GetRectMinX(gg_rct_MAP)
    private real maxY = GetRectMaxY(gg_rct_MAP)
    private real minY = GetRectMinY(gg_rct_MAP)
endglobals

private function Actions takes nothing returns nothing
    local integer i = 19
    loop
        exitwhen i == 0 // Why like this? &gt; is more operation heavy than ==
        call CreateItem( udg_Items[GetRandomInt(1, 9)], GetRandomReal( minX, maxX ), GetRandomReal( minY, maxY )) // Inline the GetRandom&#039;s
        set i = i - 1
    endloop
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    call TimerStart( CreateTimer(), 90.00, true, function Actions ) // Timer more efficient than Trigger in this case
endfunction
endscope


And the second:

JASS:
scope MuzzleFlash initializer Init // Scope == Encapsulation
    globals
        private constant string MODEL = &quot;war3mapImported\\Konstrukt_ShotgunEffektAttachment.MDX&quot; // Model Path
        private constant string ATTACH = &quot;weapon&quot; // Attachment Point
        private constant real WAIT_TIME = 1.00 // Wait Time
    endglobals
    
    private function Actions takes nothing returns nothing
        local effect e = AddSpecialEffectTarget(MODEL, GetTriggerUnit(), ATTACH)
        call TriggerSleepAction(WAIT_TIME) // For this, TSA is fine, accuracy isn&#039;t exactly needed
        call DestroyEffect(e) // Flush leaks
        set e = null
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED) // BJ will be fine for this, if you seriously want efficiency, just convert to native version
        call TriggerAddAction(t, function Actions)
    endfunction
endscope
 

xoxdragonxox

New Member
Reaction score
1
Ugh. I dont have NewGen lol =[ i dont like using those tools lol. is there a way to optmize it without newgen, and if anyone can kindly help me with the 2nd gui I'd greatly appreciate it

Thanks with the help so far guys !
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
I dont have NewGen lol =[ i dont like using those tools

your kidding right? everybody loves NewGen :p

all you have to do is download it and run it

anyway, try using my code then
 

xoxdragonxox

New Member
Reaction score
1
None are working without newgen. and i just tried to download newgen and its just giving me allot of problems, lots of dll's missing and corrupted files, invalid start up files missing and crap lol i tried to use it before, same problem i think its my pc iunno.

and like i said none of the triggers u have have will work without newgen:banghead:
 

Sevion

The DIY Ninja
Reaction score
413
Whoops, I forgot the conditions :(

Here's them without vJASS implementations:

JASS:
// Put globals into the map header
globals // Why globals? They never change unless you move the rect. Which... you never do, do you? If you do, just reset them <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
    real maxX = GetRectMaxX(gg_rct_MAP)
    real minX = GetRectMinX(gg_rct_MAP)
    real maxY = GetRectMaxY(gg_rct_MAP)
    real minY = GetRectMinY(gg_rct_MAP)
endglobals

function Actions takes nothing returns nothing
    local integer i = 19
    loop
        exitwhen i == 0 // Why like this? &gt; is more operation heavy than ==
        call CreateItem( udg_Items[GetRandomInt(1, 9)], GetRandomReal( minX, maxX ), GetRandomReal( minY, maxY )) // Inline the GetRandom&#039;s
        set i = i - 1
    endloop
endfunction

//===========================================================================
function InitTrig_Items takes nothing returns nothing
    call TimerStart( CreateTimer(), 90.00, true, function Actions ) // Timer more efficient than Trigger in this case
endfunction


JASS:
// Put globals into Map Header
    globals
        constant string MODEL = &quot;war3mapImported\\Konstrukt_ShotgunEffektAttachment.MDX&quot; // Model Path
        constant string ATTACH = &quot;weapon&quot; // Attachment Point
        constant real WAIT_TIME = 1.00 // Wait Time
    endglobals
    
     function Actions takes nothing returns nothing
        local effect e = AddSpecialEffectTarget(MODEL, GetTriggerUnit(), ATTACH)
        call TriggerSleepAction(WAIT_TIME) // For this, TSA is fine, accuracy isn&#039;t exactly needed
        call DestroyEffect(e) // Flush leaks
        set e = null
    endfunction

    function Conditions takes nothing returns boolean
        return GetUnitTypeId(GetFilterUnit(), UNIT_TYPE_HERO) and udg_Reload[GetPlayerId(GetOwningPlayer(GetFilterUnit()))] == 0
    endfunction
    
    function InitTrig_MuzzleFlash takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED) // BJ will be fine for this, if you seriously want efficiency, just convert to native version
        call TriggerAddCondition(t, Filter(function Conditions))
        call TriggerAddAction(t, function Actions)
    endfunction


By the way, jig7c, does the timer continue to run if you destroy without pausing? I believe it does, but am not sure :(

You could also inline the conditions and actions... but... I'm being lazy :(
 

Laiev

Hey Listen!!
Reaction score
188
>> By the way, jig7c, does the timer continue to run if you destroy without pausing? I believe it does, but am not sure

The timer stop but can bug some times (don't know what post i read it), so the most recommended thing is pause and then destroy it.
 

Flare

Stops copies me!
Reaction score
662
JASS:
call DestroyTimer (TimerStart( CreateTimer(), 90.00, true, function Actions ))

That wouldn't work
JASS:
native TimerStart           takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing

TimerStart doesn't return any timer, so you would essentially be doing
JASS:
call DestroyTimer (nothing) //if you could call &#039;nothing&#039; a valid type <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />


The timer stop but can bug some times (don't know what post i read it), so the most recommended thing is pause and then destroy it.
From what I recall from Rising_Dusk's timer tutorial (although, it's been some time since I've had a read of it :p), a timer will continue to count down if destroyed while running OR, if it's repeating, it will do another countdown if destroyed within its callback function - not 100% certain on this, and laziness gets the better of me when it comes to finding these threads :p

Oh sorry one more thing, cant i just combine those 2 globals into one or do they need to be seperate globals?
You haven't actually identified which globals you are talking about, but I would imagine it's extremely unlikely.
 

xoxdragonxox

New Member
Reaction score
1
Uhmm. I just tried to put the 2 triggers into my map and i did put the globals in and im getting 1522 Compile Errors. when i remove the triggers it compiles properly :thdown:
 

Sevion

The DIY Ninja
Reaction score
413
It should be like this in the map header (if you don't have NewGen):

JASS:
globals
    constant string MODEL = &quot;war3mapImported\\Konstrukt_ShotgunEffektAttachment.MDX&quot; // Model Path
    constant string ATTACH = &quot;weapon&quot; // Attachment Point
    constant real WAIT_TIME = 1.00 // Wait Time
    real maxX = GetRectMaxX(gg_rct_MAP)
    real minX = GetRectMinX(gg_rct_MAP)
    real maxY = GetRectMaxY(gg_rct_MAP)
    real minY = GetRectMinY(gg_rct_MAP)
endglobals
 

xoxdragonxox

New Member
Reaction score
1
Im a lost case right now :thdown:

So it wont work? lol if not thats totaly fine you guys have tried to help me :thup:
 

xoxdragonxox

New Member
Reaction score
1
Ugh. Still not working . Im pretty sure im putting it all in properly. i get 9 errors and the 9 are the trigger i put in the map header

I put this in the map header
JASS:
globals
    constant string MODEL = &quot;war3mapImported\\Konstrukt_ShotgunEffektAttachment.MDX&quot; // Model Path
    constant string ATTACH = &quot;weapon&quot; // Attachment Point
    constant real WAIT_TIME = 1.00 // Wait Time
    real maxX = GetRectMaxX(gg_rct_MAP)
    real minX = GetRectMinX(gg_rct_MAP)
    real maxY = GetRectMaxY(gg_rct_MAP)
    real minY = GetRectMinY(gg_rct_MAP)
endglobals


and these as my 2 triggeres

JASS:
function Actions takes nothing returns nothing
    local integer i = 19
    loop
        exitwhen i == 0 // Why like this? &gt; is more operation heavy than ==
        call CreateItem( udg_Items[GetRandomInt(1, 9)], GetRandomReal( minX, maxX ), GetRandomReal( minY, maxY )) // Inline the GetRandom&#039;s
        set i = i - 1
    endloop
endfunction

//===========================================================================
function InitTrig_Items takes nothing returns nothing
    call TimerStart( CreateTimer(), 90.00, true, function Actions ) // Timer more efficient than Trigger in this case
endfunction


and

JASS:
     function Actions takes nothing returns nothing
        local effect e = AddSpecialEffectTarget(MODEL, GetTriggerUnit(), ATTACH)
        call TriggerSleepAction(WAIT_TIME) // For this, TSA is fine, accuracy isn&#039;t exactly needed
        call DestroyEffect(e) // Flush leaks
        set e = null
    endfunction

    function Conditions takes nothing returns boolean
        return GetUnitTypeId(GetFilterUnit(), UNIT_TYPE_HERO) and udg_Reload[GetPlayerId(GetOwningPlayer(GetFilterUnit()))] == 0
    endfunction
    
    function InitTrig_MuzzleFlash takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED) // BJ will be fine for this, if you seriously want efficiency, just convert to native version
        call TriggerAddCondition(t, Filter(function Conditions))
        call TriggerAddAction(t, function Actions)
    endfunction
 
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