• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Mixing JASS and GUI

Status
Not open for further replies.
Level 13
Joined
Jan 2, 2016
Messages
978
I've seen how Bribe has combined JASS and GUI in his Damage Engine.
When I tried to do something similar, it didn't work.
Can anyone tell me how to make this work?
  • Multishot Constants
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: function Save_Properties takes nothing returns nothing
      • Set MultishotAngle = ((MultishotRange - (MultishotRange x (Power((Cos((MultishotAngle / 2.00))), 2.00)))) / (4.00 x (Cos((MultishotAngle / 2.00)))))
      • Set MultishotRange = (MultishotRange + 62.00)
      • Custom script: call SaveReal(udg_Table, udg_UnitType, StringHash("Range"), udg_MultishotRange)
      • Custom script: call SaveReal(udg_Table, udg_UnitType , StringHash("Parabola"), udg_MultishotAngle)
      • Custom script: call SaveBoolean(udg_Table, udg_UnitType , StringHash("Upgradeable"), udg_Temp_Boolean)
      • Custom script: call SaveInteger(udg_Table, udg_UnitType , StringHash("Targets"), udg_MultishotTargets)
      • Custom script: call SaveInteger(udg_Table, udg_UnitType , StringHash("AttackType"), udg_Temp_Integer)
      • Custom script: endfunction
      • -------- MultishotAngle = if the shape of the area was (but it isn't) a cone, what angle should it have in its base? (You can set it to values above 180, but then the definition of this angle would be different) --------
      • -------- MultishotRange = the range of your unit (or the range of the multishot, if they are different) --------
      • -------- MultishotTargets = the max amount of units that can be hit at once (leave to 0 if you want ALL units to be hit) --------
      • -------- Temp_Boolean = can the unit's range be upgraded with "Improved Bows" --------
      • -------- Temp_Integer = the attack type of the unit: 0 = spell; 1 = normal; 2 = pierce; 3 = siege; 4 = magic; 5 = chaos; 6 = hero --------
      • -------- Death Archer --------
      • Set UnitType = Death Archer
      • Set MultishotAngle = 50.00
      • Set MultishotRange = 900.00
      • Set MultishotTargets = 0
      • Set Temp_Integer = 5
      • Set Temp_Boolean = False
      • Custom script: call Save_Properties()
      • -------- Elite Night Elf Archer --------
      • Set UnitType = Elite Night Elf Archer
      • Set MultishotAngle = 40.00
      • Set MultishotRange = 600.00
      • Set MultishotTargets = 3
      • Set Temp_Integer = 2
      • Set Temp_Boolean = True
      • Custom script: call Save_Properties()
I don't want to manually save the values every time they are set, I just want to call the saving function, but right now the JASS version look like:
JASS:
function gg_trg_Multishot_Constants_Actions takes nothing returns nothing
    function Save_Properties takes nothing returns nothing

P.S. I know it will work if I put the JASS text in the map's custom script, but I wanna know how to do it like Bribe xP
 
Level 12
Joined
May 22, 2015
Messages
1,051
I always get confused trying to think this through my head.

You have to close the top function before making a new one. You basically just add another custom script for "endfunction".

However, I don't understand how the trigger gets set up properly if you do that. It would mean the normal actions for the trigger do nothing. Adding the endfunction at the bottom means your new function will be below the actions function when you convert to JASS, so you wouldn't be able to call the function from inside the actions function (it would basically be unusable). I assume I am either missing a piece of the puzzle or I just don't understand a part correctly.

Anyway, I never saw a good reason to mix them together like this (except to call simple functions you normally can't - like for clearing leaks). I would just go full JASS unless you have some specific reason to keep it GUI. It runs faster (if you do it right) and is easier to read and edit (if you know JASS).
 
Level 13
Joined
Jan 2, 2016
Messages
978
I know that I wouldn't be able to call my function if I end the original function.
Bribe uses some "Execute function" command (or execute trigger, can't be bothered to check right now). Last time I tried to find the function he was executing (in GUI) - I couldn't. Maybe I missed it, cuz his trigger is quite long. I converted his trigger to JASS, and I managed to find the function.
What's odd is that the function he was executing was below the actions of the trigger.

Anyways.. I want to keep it GUI, cuz this is my configurations trigger. It doesn't do anything, but save some variables in a hashtable.

EDIT: I actually got curious and looked at his Damage Engine again. Found the function in the bottom of his trigger.
 
Level 13
Joined
Jan 2, 2016
Messages
978
Okay, I found out how to do it:
  • Multishot Constants
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- MultishotAngle = if the shape of the area was (but it isn't) a cone, what angle should it have in its base? (You can set it to values above 180, but then the definition of this angle would be different) --------
      • -------- MultishotRange = the range of your unit (or the range of the multishot, if they are different) --------
      • -------- MultishotTargets = the max amount of units that can be hit at once (leave to 0 if you want ALL units to be hit) --------
      • -------- Temp_Boolean = can the unit's range be upgraded with "Improved Bows" --------
      • -------- Temp_Integer = the attack type of the unit: 0 = spell; 1 = normal; 2 = pierce; 3 = siege; 4 = magic; 5 = chaos; 6 = hero --------
      • -------- Death Archer --------
      • Set UnitType = Death Archer
      • Set MultishotAngle = 50.00
      • Set MultishotRange = 900.00
      • Set MultishotTargets = 0
      • Set Temp_Integer = 5
      • Set Temp_Boolean = False
      • Custom script: call ExecuteFunc("Save_Properties")
      • -------- Elite Night Elf Archer --------
      • Set UnitType = Elite Night Elf Archer
      • Set MultishotAngle = 40.00
      • Set MultishotRange = 600.00
      • Set MultishotTargets = 3
      • Set Temp_Integer = 2
      • Set Temp_Boolean = True
      • Custom script: call ExecuteFunc("Save_Properties")
      • Custom script: endfunction
      • Custom script: function Save_Properties takes nothing returns nothing
      • Set MultishotAngle = ((MultishotRange - (MultishotRange x (Power((Cos((MultishotAngle / 2.00))), 2.00)))) / (4.00 x (Cos((MultishotAngle / 2.00)))))
      • Set MultishotRange = (MultishotRange + 62.00)
      • Custom script: call SaveReal(udg_Table, udg_UnitType, StringHash("Range"), udg_MultishotRange)
      • Custom script: call SaveReal(udg_Table, udg_UnitType , StringHash("Parabola"), udg_MultishotAngle)
      • Custom script: call SaveBoolean(udg_Table, udg_UnitType , StringHash("Upgradeable"), udg_Temp_Boolean)
      • Custom script: call SaveInteger(udg_Table, udg_UnitType , StringHash("Targets"), udg_MultishotTargets)
      • Custom script: call SaveInteger(udg_Table, udg_UnitType , StringHash("AttackType"), udg_Temp_Integer)
 
Level 12
Joined
May 22, 2015
Messages
1,051
I've never used ExecuteFunc. Oh well. I think I will stick to full JASS :D I hate working in GUI after learning JASS lol
 

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,239
vjass stuff.

Seriously doesn't it give you an error? In order to call a function said function needs to be above the function that is calling. And your is bellow..
Is that a benefit of ExecuteFunc() perhaps..

edit: confirmed.
If you would call Function() instead of call ExecuteFunc("Function") it would give an error. Today I learned something.
 
Status
Not open for further replies.
Top