[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.
  • 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
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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