Hi everyone
i want to convert all of my GUI triggers into JASS, remove BJ functions, create local variables...
i am not familiar with JASS, but that is what i came up with:
the JASS trigger has the same ingame result as the GUI trigger now, but i want to know if there is anything to improve (and there is for sure) and i hope you guys can give me some tips for a beginner
thanks
i want to convert all of my GUI triggers into JASS, remove BJ functions, create local variables...
i am not familiar with JASS, but that is what i came up with:
-
Pick Hero GUI
-
Ereignisse
-
Einheit - A unit Erwirbt einen Gegenstand
-
-
Bedingungen
-
(Unit-type of (Hero manipulating item)) Gleich Dummy_Select
-
-
Aktionen
-
Set TempPlayer = (Owner of (Triggering unit))
-
Set TempInt = (Player number of TempPlayer)
-
For each (Integer Int) from 1 to 7, do (Actions)
-
Schleifen - Aktionen
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
'IF'-Bedingungen
-
(Item-type of (Item being manipulated)) Gleich GoblinIcon[Int]
-
-
'THEN'-Aktionen
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
'IF'-Bedingungen
-
Int Ungleich 7
-
-
'THEN'-Aktionen
-
Set TempInt2 = Int
-
Set TempString = chosen
-
-
'ELSE'-Aktionen
-
Set TempInt2 = (Random integer number between 1 and 6)
-
Set TempString = randomed
-
-
-
-
'ELSE'-Aktionen
-
-
-
-
Set TempInt3 = (Random integer number between 1 and 8)
-
Set TempPoint = (Random point in (Load DialogIndex_Area of TempInt3 in RegionHash))
-
Einheit - Create 1 Goblin[TempInt2] for TempPlayer at TempPoint facing Vorgabe für Gebäude-Ausrichtung degrees
-
Set TempUnit1 = (Last created unit)
-
Auswahl - Select TempUnit1 for TempPlayer
-
Einheitengruppe - Add TempUnit1 to UnitGroup
-
Kamera - Pan camera for TempPlayer to TempPoint over 1.00 seconds
-
Spiel - Display to (All players) the text: (Player[TempInt] + (( |rhas + (TempString + |cff7ebff1)) + (Name of TempUnit1)))
-
Custom script: call RemoveLocation (udg_TempPoint)
-
Held - Create Item[0] and give it to TempUnit1
-
-
JASS:
function PickHeroConditions takes nothing returns boolean
if ( GetUnitTypeId(GetManipulatingUnit()) == 'h00D' ) then
return true
endif
return false
endfunction
function PickHeroActions takes nothing returns nothing
local player p = GetOwningPlayer(GetTriggerUnit())
local unit u
local integer player_id = GetPlayerId(p) + 1
local integer unit_id
local integer i = 1
local string output
local location spawn = GetRandomLocInRect(LoadRectHandle(udg_RegionHash, GetRandomInt(1, 8), udg_DialogIndex_Area))
local real x = GetLocationX(spawn)
local real y = GetLocationY(spawn)
loop
exitwhen i > 10
if(GetItemTypeId(GetManipulatedItem()) == udg_GoblinIcon[i]) then
if (i != 7) then
set unit_id = i
set output = "chosen"
else
set unit_id = GetRandomInt(1, 6)
set output = "randomed"
endif
endif
set i = i + 1
endloop
set u = CreateUnit(p, udg_Goblin[unit_id], x, y, bj_UNIT_FACING)
call GroupAddUnit(udg_UnitGroup, u)
if (GetLocalPlayer() == p) then
call PanCameraToTimed(x, y, 1.00)
endif
if (GetLocalPlayer() == p) then
call ClearSelection()
call SelectUnit(u, true)
endif
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, udg_Player[player_id] + ((" |rhas " + (output + " |cff7ebff1")) + GetUnitName(u)))
set bj_lastCreatedItem = CreateItem(udg_Item[0], x, y)
call UnitAddItem(u,bj_lastCreatedItem)
set u = null
set p = null
set spawn = null
endfunction
//===========================================================================
function InitTrig_Pick_Hero takes nothing returns nothing
set gg_trg_Pick_Hero = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Pick_Hero, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( gg_trg_Pick_Hero, Condition( function PickHeroConditions ) )
call TriggerAddAction( gg_trg_Pick_Hero, function PickHeroActions )
endfunction
the JASS trigger has the same ingame result as the GUI trigger now, but i want to know if there is anything to improve (and there is for sure) and i hope you guys can give me some tips for a beginner
thanks