• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Import GUI into JASS

Status
Not open for further replies.
Level 10
Joined
Jun 20, 2017
Messages
333
First my jass is not good, second I try import these GUI into JASS, But they are broken and won't work, I also get a lot of errors.
gui
  • Attack Destroy Building
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Multiple ConditionsAnd - All (Conditions) are true
        • Conditions
          • ((Attacking unit) is A peon-type unit) Equal to (==) True
          • ((Attacked unit) is A structure) Equal to (==) True
          • (Owner of (Attacking unit)) Equal to (==) (Owner of (Attacked unit))
          • (Unit-type of (Attacked unit)) Not equal to (!=) Flag
    • Actions
      • Wait 0.50 seconds
      • Unit - Kill (Attacked unit)
  • Cannot attack ally
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Multiple ConditionsAnd - All (Conditions) are true
        • Conditions
          • ((Attacked unit) is An Ancient) Equal to (==) True
          • ((Attacking unit) belongs to an ally of (Owner of (Attacked unit))) Equal to (==) True
    • Actions
      • Unit - Order (Attacking unit) to Stop
  • Attack Heroic Heartbreak
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Multiple ConditionsOr - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacking unit)) Equal to (==) Kael
          • (Unit-type of (Attacking unit)) Equal to (==) Arthas
          • (Unit-type of (Attacking unit)) Equal to (==) Maiev
          • (Unit-type of (Attacking unit)) Equal to (==) Malfurion
          • (Unit-type of (Attacking unit)) Equal to (==) Rexxar
          • (Unit-type of (Attacking unit)) Equal to (==) Marine
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item carried by (Attacking unit) of type Heroic-Heartbreak)) Equal to (==) Heroic-Heartbreak
          • ((Owner of (Attacking unit)) is an ally of (Owner of (Attacked unit))) Not equal to (!=) True
          • (Owner of (Attacking unit)) Not equal to (!=) (Owner of (Attacked unit))
        • Then - Actions
          • Unit - Kill (Attacked unit)
          • Trigger - Turn on Heroic Heartbreak <gen>
          • Trigger - Turn on Vampires Dead <gen>
        • Else - Actions
jass
JASS:
function Trig_Attack_Func001C takes nothing returns boolean
    if ( not ( IsUnitType(GetAttacker(), UNIT_TYPE_PEON) == true ) ) then
        return false
    endif
    if ( not ( IsUnitType(GetAttackedUnitBJ(), UNIT_TYPE_STRUCTURE) == true ) ) then
        return false
    endif
    if ( not ( GetOwningPlayer(GetAttacker()) == GetOwningPlayer(GetAttackedUnitBJ()) ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetAttackedUnitBJ()) != 'h00B' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Attack_Conditions takes nothing returns boolean
    if ( not Trig_Attack_Func001C() ) then
        return false
    endif
    return true
endfunction

function Trig_Attack_Actions takes nothing returns nothing
    call TriggerSleepAction( 0.50 )
    call KillUnit( GetAttackedUnitBJ() )
endfunction

//===========================================================================
function InitTrig_Attack takes nothing returns nothing
    set gg_trg_Attack = CreateTrigger(  )
    call DisableTrigger( gg_trg_Attack )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Attack, Condition( function Trig_Attack_Conditions ) )
    call TriggerAddAction( gg_trg_Attack, function Trig_Attack_Actions )
endfunction
JASS:
function Trig_Cannot_attack_ally_Func001C takes nothing returns boolean
    if ( not ( IsUnitType(GetAttackedUnitBJ(), UNIT_TYPE_ANCIENT) == true ) ) then
        return false
    endif
    if ( not ( IsUnitAlly(GetAttacker(), GetOwningPlayer(GetAttackedUnitBJ())) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Cannot_attack_ally_Conditions takes nothing returns boolean
    if ( not Trig_Cannot_attack_ally_Func001C() ) then
        return false
    endif
    return true
endfunction

function Trig_Cannot_attack_ally_Actions takes nothing returns nothing
    call IssueImmediateOrder( GetAttacker(), "stop" )
endfunction

//===========================================================================
function InitTrig_Cannot_attack_ally takes nothing returns nothing
    set gg_trg_Cannot_attack_ally = CreateTrigger(  )
    call DisableTrigger( gg_trg_Cannot_attack_ally )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Cannot_attack_ally, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Cannot_attack_ally, Condition( function Trig_Cannot_attack_ally_Conditions ) )
    call TriggerAddAction( gg_trg_Cannot_attack_ally, function Trig_Cannot_attack_ally_Actions )
endfunction
JASS:
function Trig_Attack_Heroic_Heartbreak_Func001C takes nothing returns boolean
    if ( ( GetUnitTypeId(GetAttacker()) == 'H019' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetAttacker()) == 'H024' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetAttacker()) == 'H025' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetAttacker()) == 'H026' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetAttacker()) == 'H027' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetAttacker()) == 'H004' ) ) then
        return true
    endif
    return false
endfunction

function Trig_Attack_Heroic_Heartbreak_Conditions takes nothing returns boolean
    if ( not Trig_Attack_Heroic_Heartbreak_Func001C() ) then
        return false
    endif
    return true
endfunction

function Trig_Attack_Heroic_Heartbreak_Func002C takes nothing returns boolean
    if ( not ( GetItemTypeId(GetItemOfTypeFromUnitBJ(GetAttacker(), 'I00M')) == 'I00M' ) ) then
        return false
    endif
    if ( not ( IsPlayerAlly(GetOwningPlayer(GetAttacker()), GetOwningPlayer(GetAttackedUnitBJ())) != true ) ) then
        return false
    endif
    if ( not ( GetOwningPlayer(GetAttacker()) != GetOwningPlayer(GetAttackedUnitBJ()) ) ) then
        return false
    endif
    return true
endfunction

function Trig_Attack_Heroic_Heartbreak_Actions takes nothing returns nothing
    if ( Trig_Attack_Heroic_Heartbreak_Func002C() ) then
        call KillUnit( GetAttackedUnitBJ() )
        call EnableTrigger( gg_trg_Heroic_Heartbreak )
        call EnableTrigger( gg_trg_Vampires_Dead )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Attack_Heroic_Heartbreak takes nothing returns nothing
    set gg_trg_Attack_Heroic_Heartbreak = CreateTrigger(  )
    call DisableTrigger( gg_trg_Attack_Heroic_Heartbreak )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack_Heroic_Heartbreak, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Attack_Heroic_Heartbreak, Condition( function Trig_Attack_Heroic_Heartbreak_Conditions ) )
    call TriggerAddAction( gg_trg_Attack_Heroic_Heartbreak, function Trig_Attack_Heroic_Heartbreak_Actions )
endfunction
my jass
JASS:
function Trig_Attack_Cannot_Attack_Actions takes nothing returns nothing
    local unit Attacker = GetAttacker()
    local unit Attacked = GetTriggerUnit()
    //Attack Destroy Building
    if IsUnitType(Attacker, UNIT_TYPE_PEON) == true then
    elseif IsUnitType(Attacked, UNIT_TYPE_STRUCTURE) == true then
    elseif GetOwningPlayer(Attacker) == GetOwningPlayer(Attacked) then
    elseif GetUnitTypeId(Attacked) != 'h00B' then
    elseif TriggerSleepAction(0.50)
    elseif KillUnit(Attacked)
    call TriggerSleepAction(0.50)
    call KillUnit(Attacked)
    //Attack Heroic Heartbreak
    elseif GetUnitTypeId(Attacker) == 'H019' then
    elseif GetUnitTypeId(Attacker) == 'H024' then
    elseif GetUnitTypeId(Attacker) == 'H025' then
    elseif GetUnitTypeId(Attacker) == 'H026' then
    elseif GetUnitTypeId(Attacker) == 'H027' then
    elseif GetUnitTypeId(Attacker) == 'H004' then
    elseif GetItemTypeId(GetItemOfTypeFromUnitBJ(Attacker, 'I00M')) == 'I00M' then
    elseif IsPlayerAlly(GetOwningPlayer(Attacker), GetOwningPlayer(Attacked) != true) then
    elseif GetOwningPlayer(Attacker) != GetOwningPlayer(Attacked) then
    call KillUnit(Attacked)
    call EnableTrigger(gg_trg_Heroic_Heartbreak)
    call EnableTrigger(gg_trg_Vampires_Dead)
    //Cannot Attack Ally
    elseif IsUnitType(Attacked, UNIT_TYPE_ANCIENT) == true then
    elseif IsUnitAlly(Attacker, GetOwningPlayer(Attacked)) == true then
    call IssueImmediateOrder(Attacker, "stop")
    //UnitGroup_Vampires
    elseif IsUnitInGroup(Attacked, udg_UnitGroup_Vampires) == true then
    elseif IsUnitInGroup(Attacker, udg_UnitGroup_Vampires) == true then
    call IssueImmediateOrder(Attacker, "stop")
    //Shadow Wolf - Security Helper
    elseif GetUnitTypeId(Attacker) == 'o003' then
    elseif GetUnitTypeId(Attacked) != 'h00I' then
    call IssueImmediateOrder(Attacker, "stop")
    //Grave
    elseif IsUnitInGroup(Attacker, udg_UnitGroup_Humans) == true then
    elseif GetOwningPlayer(Attacker) != GetOwningPlayer(Attacked) then
    elseif IsUnitAlly(Attacked, GetOwningPlayer(Attacker)) then
    elseif GetUnitTypeId(Attacked) != 'u002' then
    call IssueImmediateOrder(Attacker, "stop")
    //Flag
    elseif IsUnitInGroup(Attacker, udg_UnitGroup_Vampires) != true
    call IssueImmediateOrder(Attacker, "stop")
    endif
    set Attacker = null
    set Attacked = null
endfunction

//Flag
function Trig_Attack_Cannot_Attack1_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'h00B'
endfunction

//===========================================================================
function InitTrig_Attack_Cannot_Attack takes nothing returns nothing
    set gg_trg_Attack_Cannot_Attack = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Attack_Cannot_Attack, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(gg_trg_Attack_Cannot_Attack, Condition(function Trig_Attack_Cannot_Attack1_Conditions))
    call TriggerAddAction(gg_trg_Attack_Cannot_Attack, function Trig_Attack_Cannot_Attack_Actions)
endfunction
 
Last edited:

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,890
JASS:
function Trig_Attack_Cannot_Attack_Actions takes nothing returns nothing
    local unit Attacker = GetAttacker()
    local unit Attacked = GetTriggerUnit()
    //Attack Destroy Building
    if IsUnitType(Attacker, UNIT_TYPE_PEON) == true then //Nothing happens if true (??)
    elseif IsUnitType(Attacked, UNIT_TYPE_STRUCTURE) == true then //Nothing happens if true (??)
    elseif GetOwningPlayer(Attacker) == GetOwningPlayer(Attacked) then //Nothing happens if true (??)
    elseif GetUnitTypeId(Attacked) != 'h00B' then 
    elseif TriggerSleepAction(0.50) //ERROR
    elseif KillUnit(Attacked) //ERROR
    call TriggerSleepAction(0.50)
    call KillUnit(Attacked)
    //Attack Heroic Heartbreak
    elseif GetUnitTypeId(Attacker) == 'H019' then //Nothing happens if true (??)
    elseif GetUnitTypeId(Attacker) == 'H024' then //Nothing happens if true (??)
    elseif GetUnitTypeId(Attacker) == 'H025' then //Nothing happens if true (??)
    elseif GetUnitTypeId(Attacker) == 'H026' then //Nothing happens if true (??)
    elseif GetUnitTypeId(Attacker) == 'H027' then //Nothing happens if true (??)
    elseif GetUnitTypeId(Attacker) == 'H004' then //Nothing happens if true (??)
    elseif GetItemTypeId(GetItemOfTypeFromUnitBJ(Attacker, 'I00M')) == 'I00M' then //Nothing happens if true (??)
    elseif IsPlayerAlly(GetOwningPlayer(Attacker), GetOwningPlayer(Attacked) != true) then //Nothing happens if true (??)
    elseif GetOwningPlayer(Attacker) != GetOwningPlayer(Attacked) then 
    call KillUnit(Attacked)
    call EnableTrigger(gg_trg_Heroic_Heartbreak)
    call EnableTrigger(gg_trg_Vampires_Dead)
    //Cannot Attack Ally
    elseif IsUnitType(Attacked, UNIT_TYPE_ANCIENT) == true then //Nothing happens if true (??)
    elseif IsUnitAlly(Attacker, GetOwningPlayer(Attacked)) == true then
    call IssueImmediateOrder(Attacker, "stop")
    //UnitGroup_Vampires
    elseif IsUnitInGroup(Attacked, udg_UnitGroup_Vampires) == true then //Nothing happens if true (??)
    elseif IsUnitInGroup(Attacker, udg_UnitGroup_Vampires) == true then
    call IssueImmediateOrder(Attacker, "stop")
    //Shadow Wolf - Security Helper
    elseif GetUnitTypeId(Attacker) == 'o003' then //Nothing happens if true (??)
    elseif GetUnitTypeId(Attacked) != 'h00I' then
    call IssueImmediateOrder(Attacker, "stop")
    //Grave
    elseif IsUnitInGroup(Attacker, udg_UnitGroup_Humans) == true then //Nothing happens if true (??)
    elseif GetOwningPlayer(Attacker) != GetOwningPlayer(Attacked) then //Nothing happens if true (??)
    elseif IsUnitAlly(Attacked, GetOwningPlayer(Attacker)) then //Nothing happens if true (??)
    elseif GetUnitTypeId(Attacked) != 'u002' then
    call IssueImmediateOrder(Attacker, "stop")
    //Flag
    elseif IsUnitInGroup(Attacker, udg_UnitGroup_Vampires) != true
    call IssueImmediateOrder(Attacker, "stop")
    endif
    set Attacker = null
    set Attacked = null
endfunction

//Flag
function Trig_Attack_Cannot_Attack1_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'h00B'
endfunction

//===========================================================================
function InitTrig_Attack_Cannot_Attack takes nothing returns nothing
    set gg_trg_Attack_Cannot_Attack = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Attack_Cannot_Attack, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(gg_trg_Attack_Cannot_Attack, Condition(function Trig_Attack_Cannot_Attack1_Conditions))
    call TriggerAddAction(gg_trg_Attack_Cannot_Attack, function Trig_Attack_Cannot_Attack_Actions)
endfunction
You probably meant to use "And" and "Or" conditions.
 
Level 10
Joined
Jun 20, 2017
Messages
333
JASS:
function Trig_Attack_Cannot_Attack_Actions takes nothing returns boolean
    local unit Attacker = GetAttacker()
    local unit Attacked = GetTriggerUnit()
    //Attack Destroy Building
    if IsUnitType(Attacker, UNIT_TYPE_PEON) == true then
        return false
    elseif IsUnitType(Attacked, UNIT_TYPE_STRUCTURE) == true then
        return false
    elseif GetOwningPlayer(Attacker) == GetOwningPlayer(Attacked) then
        return false
    elseif GetUnitTypeId(Attacked) != 'h00B' then
        return false
    return true
    call TriggerSleepAction(0.50)
    call KillUnit(Attacked)
    //Attack Heroic Heartbreak
    elseif GetUnitTypeId(Attacker) == 'H019' then
        return true
    elseif GetUnitTypeId(Attacker) == 'H024' then
        return true
    elseif GetUnitTypeId(Attacker) == 'H025' then
        return true
    elseif GetUnitTypeId(Attacker) == 'H026' then
        return true
    elseif GetUnitTypeId(Attacker) == 'H027' then
        return true
    elseif GetUnitTypeId(Attacker) == 'H004' then
        return true
    return false
    elseif GetItemTypeId(GetItemOfTypeFromUnitBJ(Attacker, 'I00M')) == 'I00M' then
        return false
    elseif IsPlayerAlly(GetOwningPlayer(Attacker), GetOwningPlayer(Attacked) != true) then
        return false
    elseif GetOwningPlayer(Attacker) != GetOwningPlayer(Attacked) then
        return false
    return true
    call KillUnit(Attacked)
    call EnableTrigger(gg_trg_Heroic_Heartbreak)
    call EnableTrigger(gg_trg_Vampires_Dead)
    //Cannot Attack Ally
    elseif IsUnitType(Attacked, UNIT_TYPE_ANCIENT) == true then
        return false
    elseif IsUnitAlly(Attacker, GetOwningPlayer(Attacked)) == true then
        return false
    return true
    call IssueImmediateOrder(Attacker, "stop")
    //UnitGroup_Vampires
    elseif IsUnitInGroup(Attacked, udg_UnitGroup_Vampires) == true then
        return false
    elseif IsUnitInGroup(Attacker, udg_UnitGroup_Vampires) == true then
        return false
    return true
    call IssueImmediateOrder(Attacker, "stop")
    //Shadow Wolf - Security Helper
    elseif GetUnitTypeId(Attacker) == 'o003' then
        return false
    elseif GetUnitTypeId(Attacked) != 'h00I' then
        return false
    return true
    call IssueImmediateOrder(Attacker, "stop")
    //Grave
    elseif IsUnitInGroup(Attacker, udg_UnitGroup_Humans) == true then
        return false
    elseif GetOwningPlayer(Attacker) != GetOwningPlayer(Attacked) then
        return false
    elseif IsUnitAlly(Attacked, GetOwningPlayer(Attacker)) then
        return false
    elseif GetUnitTypeId(Attacked) != 'u002' then
        return false
    return true
    call IssueImmediateOrder(Attacker, "stop")
    //Flag
    elseif IsUnitInGroup(Attacker, udg_UnitGroup_Vampires) != true
    call IssueImmediateOrder(Attacker, "stop")
    endif
    set Attacker = null
    set Attacked = null
endfunction

//Flag
function Trig_Attack_Cannot_Attack1_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'h00B'
endfunction

//===========================================================================
function InitTrig_Attack_Cannot_Attack takes nothing returns nothing
    set gg_trg_Attack_Cannot_Attack = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Attack_Cannot_Attack, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(gg_trg_Attack_Cannot_Attack, Condition(function Trig_Attack_Cannot_Attack1_Conditions))
    call TriggerAddAction(gg_trg_Attack_Cannot_Attack, function Trig_Attack_Cannot_Attack_Actions)
endfunction

How to write or any conditions are true/and any conditions are true in jass, like GUI.
And - All (Conditions) are true
Or - Any (Conditions) are true
 
Level 10
Joined
Jun 20, 2017
Messages
333
Your example in gui like this
if bool_a == true and bool_b == true and bool_c == true then
  • (((Attacking unit) is An Ancient) Equal to (==) True) and ((((Attacked unit) is A structure) Equal to (==) True) and ((Owner of (Attacking unit)) Equal to (==) (Owner of (Attacked unit))))
if bool_a == true or bool_b == true or bool_c == true then
  • (((Attacking unit) is An Ancient) Equal to (==) True) or ((((Attacked unit) is A structure) Equal to (==) True) or ((Owner of (Attacking unit)) Equal to (==) (Owner of (Attacked unit))))
but I want
And - All (Conditions) are true
Or - Any (Conditions) are true

Maybe in jass it work like this?!
JASS:
    elseif GetUnitTypeId(Attacker) == 'H019'
    elseif GetUnitTypeId(Attacker) == 'H024'
    elseif GetUnitTypeId(Attacker) == 'H025'
    elseif GetUnitTypeId(Attacker) == 'H026'
    elseif GetUnitTypeId(Attacker) == 'H027'
    elseif GetUnitTypeId(Attacker) == 'H004' then
 
Status
Not open for further replies.
Top