• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Help with Triggering AI - Guard

Status
Not open for further replies.
Level 5
Joined
Dec 10, 2007
Messages
65
Hi, ive been making a remake of an old game "Escape from Colditz" and i need to make trigger(s) which makes a guard behave in a certain way if certain conditions are met. These triggers need to be multi-instanciable, meaning that it doesnt just work for one guard, but all of the guards / prisoners.
I have already made "area" buffs which are cast to the prisoners when they step into a new area, and also the prisoners have a passive ability which tells them what nationality they are.
All area buffs are based on the "Endurance" Aura.
All nationality buffs are based on the "Bash" passive ability.

1) Guard - Prisoner in Guard uniform
The guard will run up to the prisoner dressed as a guard and stop him to ask for his pass. If he doesnt have a pass, he is sent to solitary confinement (back in original prisoner uniform) with all inventory lost. The guard cant just stop him immediatly, but needs to be a certain distance away before he can stop the prisoner. Also, if the prisoner/guard runs away he can just shoot them (if in range of a shot). The guard shouldnt just shoot straight away if the prisoner moves alittle bit then stops, he should kind of chase them till a certain distance then get out the rifle.

Ive been having trouble with this one as its abit hit and miss, they will run up to you and ask, but if u run away, they wont shoot / follow (trigger at bottom)

2) Guard - Prisoner in restricted area
The guard will run up to the prisoner, and the prisoner will have a "Caught" buff aquired meaning any guard can now chase this prisoner and capture / shoot him. Similar to the first one, but doesnt require a pass because they will just get sent straight to the solitary confinement.

Pretty much the same situation, submitted trigger at bottom.

3) Guard - Prisoner with Caught Buff
The guard will run up to the prisoner and send to solitary confinement, pretty much identical if the prisoner was in a restricted area.

4) Guard - Prisoner in other nationality quarters
A prisoner is in another nationality quarters other than their own, pretty much acts exactly like if in a restricted area.

Havent had the chance to code this one, because of the unsuccess of the other triggers.

5) Guard - Prisoner in Open Access Area at night time
A prisoner is caught in a open access area at night time, results in the same situation for if they were in a restricted area.

Same problem.

I hope someone out there can help me with these triggers because its really starting to frustrate me. I will +rep and add your name to the credits if you are successful in making these triggers work. If you need more help with me describing the actions/conditions required, just post it up and il try and help. If you need to see my triggers in action I can post up the map with it working. The triggers also dont have to be done in GUI, can be done in JAZZ, im just not that great with JAZZ.

If anyone is also wanting to help with other parts of the map, terraining, triggers, testing, general helping i could post up the map and add to the creator of the map (if enough help was given) with joint credit of the final map release :wthumbsup:

Here is some code that ive tried to make work, but its very complicated and doesnt work 100% of the time. Needs alot of work :wsad:

1) Guard - Prisoner in Guard uniform
  • guard uniform pass
    • Events
      • Unit - A unit comes within 700.00 of Nazi Guard (Rifle) 0061 <gen>
    • Conditions
      • ((Triggering player) controller) Not equal to (Neutral Passive controller)
      • ((Triggering player) controller) Not equal to (Player 2 (Blue) controller)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Nazi Guard (No Rifle)
          • (Unit-type of (Triggering unit)) Equal to Nazi Guard (Rifle)
    • Actions
      • Set Unit_Guard_Prisoner[1] = Nazi Guard (Rifle) 0061 <gen>
      • Set Unit_Guard_Prisoner[2] = (Triggering unit)
      • Set guardPost = (Position of Unit_Guard_Prisoner[1])
      • Unit - Order Unit_Guard_Prisoner[1] to Move To (Position of Unit_Guard_Prisoner[2])
      • Trigger - Turn on guard check starter <gen>
  • guard check starter (Initially off)
    • Events
      • Unit - A unit comes within 400.00 of Nazi Guard (Rifle) 0061 <gen>
    • Conditions
      • ((Triggering player) controller) Not equal to (Neutral Passive controller)
      • ((Triggering player) controller) Not equal to (Player 2 (Blue) controller)
      • Or - Any (Conditions) are true
        • (Unit-type of (Triggering unit)) Equal to Nazi Guard (No Rifle)
        • (Unit-type of (Triggering unit)) Equal to Nazi Guard (Rifle)
    • Actions
      • Trigger - Turn on guard loop checker <gen>
      • Trigger - Turn off guard uniform pass <gen>
      • Trigger - Turn off (This trigger)
  • guard loop checker (initially off)
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
      • Kill Equal to False
    • Actions
      • Set GuardDistance = (Distance between (Position of Unit_Guard_Prisoner[1]) and (Position of Unit_Guard_Prisoner[2])))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GuardDistance Less than or equal to 500.00
        • Then - Actions
          • Unit - Order Unit_Guard_Prisoner[1] to Move To (Position of Unit_Guard_Prisoner[2])
          • Wait 2.50 seconds
          • Unit - Order Unit_Guard_Prisoner[1] to Stop
        • Else - Actions
          • Set Kill = True
          • Unit - Order Unit_Guard_Prisoner[1] to Attack Unit_Guard_Prisoner[2]
  • Take Pass or DIE
    • Events
      • Unit - A unit comes within 100.00 of Nazi Guard (Rifle) 0061 <gen>
    • Conditions
      • ((Triggering player) controller) Not equal to (Player 2 (Blue) controller)
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Nazi Guard (No Rifle)
          • (Unit-type of (Triggering unit)) Equal to Nazi Guard (Rifle)
    • Actions
      • Set Kill = False
      • Unit - Order Nazi Guard (Rifle) 0061 <gen> to Stop
      • Trigger - Turn off guard loop checker <gen>
      • Wait 0.02 seconds
      • Game - Display to Player Group - Player 1 (Red) the text: Guard: Stop right there! Hand over your pass!
      • Sound - Play ArrangedTeamInvitation <gen>
      • Unit - Change ownership of (Triggering unit) to Neutral Passive and Retain color
      • Wait 0.02 seconds
      • Selection - select (Triggering unit)
      • Wait 0.02 seconds
      • Unit - Order (Triggering unit) to Stop
      • Wait 1.50 seconds
      • Unit - Make (Triggering unit) face Nazi Guard (Rifle) 0061 <gen> over 1.50 seconds
      • Wait 1.50 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item carried by (Triggering unit) of type Pass) is owned) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by (Triggering unit) of type Pass)) Equal to 1
            • Then - Actions
              • Item - Remove (Item carried by (Triggering unit) of type Pass)
            • Else - Actions
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Pass) to ((Charges remaining in (Item carried by (Triggering unit) of type Pass)) - 1)
          • Wait 0.00 seconds
          • Game - Display to Player Group - Player 1 (Red) the text: You have been ordered to hand over a pass.
          • Wait 0.00 seconds
          • Sound - Play QuestCompleted <gen>
          • Wait 1.50 seconds
          • Unit - Order Nazi Guard (Rifle) 0061 <gen> to Move To guardPost
          • Wait 1.00 seconds
          • Unit - Change ownership of (Triggering unit) to Player 1 (Red) and Retain color
          • Wait 0.02 seconds
          • Selection - Select (Triggering unit)
          • Wait 0.02 seconds
          • Player - Make Player 2 (Blue) treat Player 1 (Red) as an Ally
          • Wait 10.00 seconds
          • Trigger - Turn on guard uniform pass <gen>
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: You have been caught without a pass and been sent to solitary confinement.
          • Wait 0.00 seconds
          • Sound - Play QuestFailed <gen>
          • Wait 1.50 seconds
          • Unit - Move (Triggering unit) instantly to (Center of solitaryCELL10 <gen>)
          • Wait 0.02 seconds
          • Camera - Pan camera for Player 1 (Red) to (Center of solitaryCELL10 <gen>) over 0.00 seconds
          • Wait 0.02 seconds
          • Unit - Change ownership of (Triggering unit) to Player 1 (Red) and Retain color
          • Wait 0.02 seconds
          • Unit - Replace (Triggering unit) with a Prisoner (Male 2) using The old unit's relative life and mana
          • Wait 0.02 seconds
          • Selection - Select (Last replaced unit)
          • Wait 0.02 seconds
          • Sound - Play BattleNetDoorsStereo2 <gen>
          • Wait 0.02 seconds
          • Trigger - Turn on guard uniform pass <gen>

2) Guard - Prisoner in restricted area
  • prisoner restricted
    • Events
      • Unit - A unit comes within 700.00 of Nazi Guard (Rifle) 0131 <gen>
    • Conditions
      • ((Triggering player) controller) Not equal to (Neutral Passive controller)
      • ((Triggering player) controller) Not equal to (Player 2 (Blue) controller)
      • (Unit-type of (Triggering unit)) Equal to Prisoner (Male 2)
      • Or - Any (Conditions) are true
        • Conditions
          • ((Triggering unit) has buff Caught ) Equal to True
          • ((Triggering unit) has buff Restricted Area ) Equal to True
    • Actions
      • Set Unit_Guard_Prisoner[1] = Nazi Guard (Rifle) 0131 <gen>
      • Set Unit_Guard_Prisoner[2] = (Triggering unit)
      • Set guardPost = (Position of Unit_Guard_Prisoner[1])
      • Unit - Order Unit_Guard_Prisoner[1] to Move To (Position of Unit_Guard_Prisoner[2])
      • Unit - Add Caught (Endurance Aura) to (Triggering unit)
      • Trigger - Turn on prisoner check starter
  • prisoner check starter (initially off)
    • Events
      • Unit - A unit comes within 400.00 of Nazi Guard (Rifle) 0131 <gen>
    • Conditions
      • ((Triggering player) controller) Not equal to (Neutral Passive controller)
      • ((Triggering player) controller) Not equal to (Player 2 (Blue) controller)
      • (Unit-type of (Triggering unit)) Equal to Prisoner (Male 2)
    • Actions
      • Trigger - Turn on prisoner loop checker <gen>
      • Trigger - Turn off prisoner restricted <gen>
      • Trigger - Turn off (This trigger)
  • prisoner loop checker (Initially off)
    • Conditions
      • Kill Equal to False
    • Actions
      • Set GuardDistance = (Distance between (Position of Unit_Guard_Prisoner[1]) and (Position of Unit_Guard_Prisoner[2])))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Guard Distance Less then or equal to 500.00
        • Then - Actions
          • Unit - Order Unit_Guard_Prisoner[1] to Move To (Position of Unit_Guard_Prisoner[2])
          • Wait 2.50 seconds
          • Unit - Order Unit_Guard_Prisoner[1] to Stop
        • Else - Actions
          • Set Kill = True
          • Unit - Order Unit_Guard_Prisoner[1] to Attack Unit_Guard_Prisoner[2]
  • Send to solitary
    • Events
      • Unit - A unit comes within 100.00 of Nazi Guard (Rifle) 0131 <gen>
    • Conditions
      • ((Triggering player) controller) Not equal to (Player 2 (Blue) controller)
      • (Unit-type of (Triggering unit)) Equal to Prisoner (Male 2)
      • ((Triggering unit) has buff Caught ) Equal to True
    • Actions
      • Set Kill = False
      • Unit - Order Nazi Guard (Rifle) 0131 <gen> to Stop
      • Trigger - Turn off prisoner loop checker <gen>
      • Wait 0.02 seconds
      • Game - Display to Player Group - Player 1 (Red) the text: Guard: Stop right there! You are in a Restricted Area!
      • Sound - Play ArrangedTeamInvitation <gen>
      • Unit - Change ownership of (Triggering unit) to Neutral Passive and Retain color
      • Wait 0.02 seconds
      • Selection - Select (Triggering unit)
      • Wait 0.02 seconds
      • Unit - Order (Triggering unit) to Stop
      • Wait 1.50 seconds
      • Unit - Make (Triggering unit) face Nazi Guard (Rifle) 0131 <gen> over 1.50 seconds
      • Wait 1.50 seconds
      • Game - Display to Player Group - Player 1 (Red) the text: You have been caught in a restricted area and been sent to solitary confinement.
      • Wait 0.00 seconds
      • Sound - Play QuestFailed <gen>
      • Wait 1.50 seconds
      • Unit - Move (Triggering unit) instantly to (Center of solitaryCELL10 <gen>)
      • Wait 0.02 seconds
      • Camera - Pan camera for Player 1 (Red) to (Center of solitaryCELL10 <gen>) over 0.00 seconds
      • Wait 0.02 seconds
      • Unit - Change ownership of (Last replaced unit) to Player 1 (Red) and Retain color
      • Wait 0.02 seconds
      • Selection - Select (Last replaced unit)
      • Wait 0.02 seconds
      • Sound - Play BattleNetDoorsStereo2 <gen>
      • Wait 0.02 seconds
      • Trigger - Turn on guard uniform pass <gen>
 
Level 11
Joined
Aug 25, 2006
Messages
971
Sorry your reference to JAZZ threw my off. Its jass. Please call it that. If you'd like to convert it to jass the first step would be to Edit -> Convert to custom text. Then you'd move on to removing the bj's and doing all around optimization. Finally you'd begin to address the actual problems. The fact your presenting your triggers in GUI probably means you don't know any jass. If thats the case I suggest looking through the tutorials at THW and wc3campaigns.

In truth your goals aren't that complicated. If I had more time I might begin the optimization of your code. Good night...
 
Last edited:
Level 5
Joined
Dec 10, 2007
Messages
65
Ok, so i did what you said, and converted it all to custom text. This is the trigger layout:

1) Guard - Prisoner in Guard Uniform:

JASS:
function Trig_guard_uniform_pass_1_Func003C takes nothing returns boolean
    if ( ( GetUnitTypeId(GetTriggerUnit()) == 'h001' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetTriggerUnit()) == 'h000' ) ) then
        return true
    endif
    return false
endfunction

function Trig_guard_uniform_pass_1_Conditions takes nothing returns boolean
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(PLAYER_NEUTRAL_PASSIVE)) ) ) then
        return false
    endif
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(1)) ) ) then
        return false
    endif
    if ( not Trig_guard_uniform_pass_1_Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_guard_uniform_pass_1_Actions takes nothing returns nothing
    set udg_Unit_Guard_Prisoner[1] = gg_unit_h000_0061
    set udg_Unit_Guard_Prisoner[2] = GetTriggerUnit()
    set udg_guardPost = GetUnitLoc(udg_Unit_Guard_Prisoner[1])
    call IssuePointOrderLocBJ( udg_Unit_Guard_Prisoner[1], "move", GetUnitLoc(udg_Unit_Guard_Prisoner[2]) )
    call EnableTrigger( gg_trg_guard_check_starter_1 )
endfunction

//===========================================================================
function InitTrig_guard_uniform_pass_1 takes nothing returns nothing
    set gg_trg_guard_uniform_pass_1 = CreateTrigger(  )
    call TriggerRegisterUnitInRangeSimple( gg_trg_guard_uniform_pass_1, 700.00, gg_unit_h000_0061 )
    call TriggerAddCondition( gg_trg_guard_uniform_pass_1, Condition( function Trig_guard_uniform_pass_1_Conditions ) )
    call TriggerAddAction( gg_trg_guard_uniform_pass_1, function Trig_guard_uniform_pass_1_Actions )
endfunction

JASS:
function Trig_guard_check_starter_1_Func003C takes nothing returns boolean
    if ( ( GetUnitTypeId(GetTriggerUnit()) == 'h001' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetTriggerUnit()) == 'h000' ) ) then
        return true
    endif
    return false
endfunction

function Trig_guard_check_starter_1_Conditions takes nothing returns boolean
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(PLAYER_NEUTRAL_PASSIVE)) ) ) then
        return false
    endif
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(1)) ) ) then
        return false
    endif
    if ( not Trig_guard_check_starter_1_Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_guard_check_starter_1_Actions takes nothing returns nothing
    call EnableTrigger( gg_trg_guard_loop_checker_1 )
    call DisableTrigger( gg_trg_guard_uniform_pass_1 )
    call DisableTrigger( GetTriggeringTrigger() )
endfunction

//===========================================================================
function InitTrig_guard_check_starter_1 takes nothing returns nothing
    set gg_trg_guard_check_starter_1 = CreateTrigger(  )
    call DisableTrigger( gg_trg_guard_check_starter_1 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_guard_check_starter_1, 400.00, gg_unit_h000_0061 )
    call TriggerAddCondition( gg_trg_guard_check_starter_1, Condition( function Trig_guard_check_starter_1_Conditions ) )
    call TriggerAddAction( gg_trg_guard_check_starter_1, function Trig_guard_check_starter_1_Actions )
endfunction

JASS:
function Trig_guard_loop_checker_1_Conditions takes nothing returns boolean
    if ( not ( udg_Kill == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_guard_loop_checker_1_Func003C takes nothing returns boolean
    if ( not ( udg_GuardDistance <= 500.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_guard_loop_checker_1_Actions takes nothing returns nothing
    set udg_GuardDistance = DistanceBetweenPoints(GetUnitLoc(udg_Unit_Guard_Prisoner[1]), GetUnitLoc(udg_Unit_Guard_Prisoner[2]))
    if ( Trig_guard_loop_checker_1_Func003C() ) then
        call IssuePointOrderLocBJ( udg_Unit_Guard_Prisoner[1], "move", GetUnitLoc(udg_Unit_Guard_Prisoner[2]) )
        call TriggerSleepAction( 2.50 )
        call IssueImmediateOrderBJ( udg_Unit_Guard_Prisoner[1], "stop" )
    else
        set udg_Kill = true
        call IssueTargetOrderBJ( udg_Unit_Guard_Prisoner[1], "attack", udg_Unit_Guard_Prisoner[2] )
    endif
endfunction

//===========================================================================
function InitTrig_guard_loop_checker_1 takes nothing returns nothing
    set gg_trg_guard_loop_checker_1 = CreateTrigger(  )
    call DisableTrigger( gg_trg_guard_loop_checker_1 )
    call TriggerRegisterTimerEventPeriodic( gg_trg_guard_loop_checker_1, 3.00 )
    call TriggerAddCondition( gg_trg_guard_loop_checker_1, Condition( function Trig_guard_loop_checker_1_Conditions ) )
    call TriggerAddAction( gg_trg_guard_loop_checker_1, function Trig_guard_loop_checker_1_Actions )
endfunction

JASS:
function Trig_Take_Pass_or_DIE_1_Func002C takes nothing returns boolean
    if ( ( GetUnitTypeId(GetTriggerUnit()) == 'h001' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetTriggerUnit()) == 'h000' ) ) then
        return true
    endif
    return false
endfunction

function Trig_Take_Pass_or_DIE_1_Conditions takes nothing returns boolean
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(1)) ) ) then
        return false
    endif
    if ( not Trig_Take_Pass_or_DIE_1_Func002C() ) then
        return false
    endif
    return true
endfunction

function Trig_Take_Pass_or_DIE_1_Func017Func001C takes nothing returns boolean
    if ( not ( GetItemCharges(GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I003')) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Take_Pass_or_DIE_1_Func017C takes nothing returns boolean
    if ( not ( IsItemOwned(GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I003')) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Take_Pass_or_DIE_1_Actions takes nothing returns nothing
    set udg_Kill = false
    call IssueImmediateOrderBJ( gg_unit_h000_0061, "stop" )
    call DisableTrigger( gg_trg_guard_loop_checker_1 )
    call TriggerSleepAction( 0.02 )
    call DisplayTextToForce( bj_FORCE_PLAYER[0], "TRIGSTR_109" )
    call PlaySoundBJ( gg_snd_ArrangedTeamInvitation )
    call SetUnitOwner( GetTriggerUnit(), Player(PLAYER_NEUTRAL_PASSIVE), false )
    call TriggerSleepAction( 0.02 )
    call SelectUnitSingle( GetTriggerUnit() )
    call TriggerSleepAction( 0.02 )
    call IssueImmediateOrderBJ( GetTriggerUnit(), "stop" )
    call TriggerSleepAction( 1.50 )
    call SetUnitFacingToFaceUnitTimed( GetTriggerUnit(), gg_unit_h000_0061, 1.50 )
    call TriggerSleepAction( 1.50 )
    if ( Trig_Take_Pass_or_DIE_1_Func017C() ) then
        if ( Trig_Take_Pass_or_DIE_1_Func017Func001C() ) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I003') )
        else
            call SetItemCharges( GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I003'), ( GetItemCharges(GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I003')) - 1 ) )
        endif
        call TriggerSleepAction( 0.00 )
        call DisplayTextToForce( bj_FORCE_PLAYER[0], "TRIGSTR_108" )
        call TriggerSleepAction( 0.00 )
        call PlaySoundBJ( gg_snd_QuestCompleted )
        call TriggerSleepAction( 1.50 )
        call IssuePointOrderLocBJ( gg_unit_h000_0061, "move", udg_guardPost )
        call TriggerSleepAction( 1.00 )
        call SetUnitOwner( GetTriggerUnit(), Player(0), false )
        call TriggerSleepAction( 0.02 )
        call SelectUnitSingle( GetTriggerUnit() )
        call TriggerSleepAction( 0.02 )
        call SetPlayerAllianceStateBJ( Player(1), Player(0), bj_ALLIANCE_ALLIED )
        call TriggerSleepAction( 10.00 )
        call EnableTrigger( gg_trg_guard_uniform_pass_1 )
    else
        call DisplayTextToForce( bj_FORCE_PLAYER[0], "TRIGSTR_110" )
        call TriggerSleepAction( 0.00 )
        call PlaySoundBJ( gg_snd_QuestFailed )
        call TriggerSleepAction( 1.50 )
        call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(gg_rct_solitaryCELL10) )
        call TriggerSleepAction( 0.02 )
        call PanCameraToTimedLocForPlayer( Player(0), GetRectCenter(gg_rct_solitaryCELL10), 0 )
        call TriggerSleepAction( 0.02 )
        call SetUnitOwner( GetTriggerUnit(), Player(0), false )
        call TriggerSleepAction( 0.02 )
        call ReplaceUnitBJ( GetTriggerUnit(), 'n000', bj_UNIT_STATE_METHOD_RELATIVE )
        call TriggerSleepAction( 0.02 )
        call SelectUnitSingle( GetLastReplacedUnitBJ() )
        call TriggerSleepAction( 0.02 )
        call PlaySoundBJ( gg_snd_BattleNetDoorsStereo2 )
        call TriggerSleepAction( 0.02 )
        call EnableTrigger( gg_trg_guard_uniform_pass_1 )
    endif
endfunction

//===========================================================================
function InitTrig_Take_Pass_or_DIE_1 takes nothing returns nothing
    set gg_trg_Take_Pass_or_DIE_1 = CreateTrigger(  )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Take_Pass_or_DIE_1, 100.00, gg_unit_h000_0061 )
    call TriggerAddCondition( gg_trg_Take_Pass_or_DIE_1, Condition( function Trig_Take_Pass_or_DIE_1_Conditions ) )
    call TriggerAddAction( gg_trg_Take_Pass_or_DIE_1, function Trig_Take_Pass_or_DIE_1_Actions )
endfunction


2) Guard - Prisoner in Restricted Area:

JASS:
function Trig_prisoner_restricted_1_Func004C takes nothing returns boolean
    if ( ( UnitHasBuffBJ(GetTriggerUnit(), 'B007') == true ) ) then
        return true
    endif
    if ( ( UnitHasBuffBJ(GetTriggerUnit(), 'B000') == true ) ) then
        return true
    endif
    return false
endfunction

function Trig_prisoner_restricted_1_Conditions takes nothing returns boolean
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(PLAYER_NEUTRAL_PASSIVE)) ) ) then
        return false
    endif
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(1)) ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'n000' ) ) then
        return false
    endif
    if ( not Trig_prisoner_restricted_1_Func004C() ) then
        return false
    endif
    return true
endfunction

function Trig_prisoner_restricted_1_Actions takes nothing returns nothing
    set udg_Unit_Guard_Prisoner[1] = gg_unit_h000_0131
    set udg_Unit_Guard_Prisoner[2] = GetTriggerUnit()
    set udg_guardPost = GetUnitLoc(udg_Unit_Guard_Prisoner[1])
    call IssuePointOrderLocBJ( udg_Unit_Guard_Prisoner[1], "move", GetUnitLoc(udg_Unit_Guard_Prisoner[2]) )
    call UnitAddAbilityBJ( 'A00J', GetTriggerUnit() )
    call EnableTrigger( gg_trg_prisoner_check_starter_1 )
endfunction

//===========================================================================
function InitTrig_prisoner_restricted_1 takes nothing returns nothing
    set gg_trg_prisoner_restricted_1 = CreateTrigger(  )
    call TriggerRegisterUnitInRangeSimple( gg_trg_prisoner_restricted_1, 700.00, gg_unit_h000_0131 )
    call TriggerAddCondition( gg_trg_prisoner_restricted_1, Condition( function Trig_prisoner_restricted_1_Conditions ) )
    call TriggerAddAction( gg_trg_prisoner_restricted_1, function Trig_prisoner_restricted_1_Actions )
endfunction

JASS:
function Trig_prisoner_check_starter_1_Conditions takes nothing returns boolean
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(PLAYER_NEUTRAL_PASSIVE)) ) ) then
        return false
    endif
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(1)) ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'n000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_prisoner_check_starter_1_Actions takes nothing returns nothing
    call EnableTrigger( gg_trg_prisoner_loop_checker_1 )
    call DisableTrigger( gg_trg_prisoner_restricted_1 )
    call DisableTrigger( GetTriggeringTrigger() )
endfunction

//===========================================================================
function InitTrig_prisoner_check_starter_1 takes nothing returns nothing
    set gg_trg_prisoner_check_starter_1 = CreateTrigger(  )
    call DisableTrigger( gg_trg_prisoner_check_starter_1 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_prisoner_check_starter_1, 400.00, gg_unit_h000_0131 )
    call TriggerAddCondition( gg_trg_prisoner_check_starter_1, Condition( function Trig_prisoner_check_starter_1_Conditions ) )
    call TriggerAddAction( gg_trg_prisoner_check_starter_1, function Trig_prisoner_check_starter_1_Actions )
endfunction

JASS:
function Trig_prisoner_loop_checker_1_Conditions takes nothing returns boolean
    if ( not ( udg_Kill == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_prisoner_loop_checker_1_Func003C takes nothing returns boolean
    if ( not ( udg_GuardDistance <= 500.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_prisoner_loop_checker_1_Actions takes nothing returns nothing
    set udg_GuardDistance = DistanceBetweenPoints(GetUnitLoc(udg_Unit_Guard_Prisoner[1]), GetUnitLoc(udg_Unit_Guard_Prisoner[2]))
    if ( Trig_prisoner_loop_checker_1_Func003C() ) then
        call IssuePointOrderLocBJ( udg_Unit_Guard_Prisoner[1], "move", GetUnitLoc(udg_Unit_Guard_Prisoner[2]) )
        call TriggerSleepAction( 2.50 )
        call IssueImmediateOrderBJ( udg_Unit_Guard_Prisoner[1], "stop" )
    else
        set udg_Kill = true
        call IssueTargetOrderBJ( udg_Unit_Guard_Prisoner[1], "attack", udg_Unit_Guard_Prisoner[2] )
    endif
endfunction

//===========================================================================
function InitTrig_prisoner_loop_checker_1 takes nothing returns nothing
    set gg_trg_prisoner_loop_checker_1 = CreateTrigger(  )
    call DisableTrigger( gg_trg_prisoner_loop_checker_1 )
    call TriggerRegisterTimerEventPeriodic( gg_trg_prisoner_loop_checker_1, 3.00 )
    call TriggerAddCondition( gg_trg_prisoner_loop_checker_1, Condition( function Trig_prisoner_loop_checker_1_Conditions ) )
    call TriggerAddAction( gg_trg_prisoner_loop_checker_1, function Trig_prisoner_loop_checker_1_Actions )
endfunction

JASS:
function Trig_Send_to_solitary_Conditions takes nothing returns boolean
    if ( not ( GetPlayerController(GetTriggerPlayer()) != GetPlayerController(Player(1)) ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'n000' ) ) then
        return false
    endif
    if ( not ( UnitHasBuffBJ(GetTriggerUnit(), 'B007') == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Send_to_solitary_Actions takes nothing returns nothing
    set udg_Kill = false
    call IssueImmediateOrderBJ( gg_unit_h000_0131, "stop" )
    call DisableTrigger( gg_trg_prisoner_loop_checker_1 )
    call TriggerSleepAction( 0.02 )
    call DisplayTextToForce( bj_FORCE_PLAYER[0], "TRIGSTR_222" )
    call PlaySoundBJ( gg_snd_ArrangedTeamInvitation )
    call SetUnitOwner( GetTriggerUnit(), Player(PLAYER_NEUTRAL_PASSIVE), false )
    call TriggerSleepAction( 0.02 )
    call SelectUnitSingle( GetTriggerUnit() )
    call TriggerSleepAction( 0.02 )
    call IssueImmediateOrderBJ( GetTriggerUnit(), "stop" )
    call TriggerSleepAction( 1.50 )
    call SetUnitFacingToFaceUnitTimed( GetTriggerUnit(), gg_unit_h000_0131, 1.50 )
    call TriggerSleepAction( 1.50 )
    call DisplayTextToForce( bj_FORCE_PLAYER[0], "TRIGSTR_225" )
    call TriggerSleepAction( 0.00 )
    call PlaySoundBJ( gg_snd_QuestFailed )
    call TriggerSleepAction( 1.50 )
    call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(gg_rct_solitaryCELL10) )
    call TriggerSleepAction( 0.02 )
    call PanCameraToTimedLocForPlayer( Player(0), GetRectCenter(gg_rct_solitaryCELL10), 0 )
    call TriggerSleepAction( 0.02 )
    call ReplaceUnitBJ( GetTriggerUnit(), 'n000', bj_UNIT_STATE_METHOD_RELATIVE )
    call TriggerSleepAction( 0.02 )
    call SetUnitOwner( GetLastReplacedUnitBJ(), Player(0), false )
    call TriggerSleepAction( 0.02 )
    call SelectUnitSingle( GetLastReplacedUnitBJ() )
    call TriggerSleepAction( 0.02 )
    call PlaySoundBJ( gg_snd_BattleNetDoorsStereo2 )
    call TriggerSleepAction( 0.02 )
    call EnableTrigger( gg_trg_guard_uniform_pass_1 )
endfunction

//===========================================================================
function InitTrig_Send_to_solitary takes nothing returns nothing
    set gg_trg_Send_to_solitary = CreateTrigger(  )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Send_to_solitary, 100.00, gg_unit_h000_0131 )
    call TriggerAddCondition( gg_trg_Send_to_solitary, Condition( function Trig_Send_to_solitary_Conditions ) )
    call TriggerAddAction( gg_trg_Send_to_solitary, function Trig_Send_to_solitary_Actions )
endfunction

Thats all the converted code into jass. Please, if anyone can help me I would greatly appreciate it. Will +rep and add to the credits of the map. Also if anyone would like any more infomation on the map, I have posted up a Map Development thread on this map found here:

http://www.hiveworkshop.com/forums/showthread.php?t=51892
 
Level 11
Joined
Aug 25, 2006
Messages
971
Ok a few things. TriggerSleepAction (also known as WAIT) can't be any faster then .3 If you set it any lower it will still wait about .29 or .3 seconds. I need to leave in about 10 minutes so I can't do anything right now. But perhaps tomorrow I'll have some time before robotics. (Which currently takes precedence over school, homework, life ... anything else in this world)
 
He also said to clean up your BJ functions. All BJs do are call a native function which is what actually does the action.

Instead of:

JASS:
[color=navy]call IssuePointOrderLocBJ( udg_Unit_Guard_Prisoner[1],"move", GetUnitLoc(udg_Unit_Guard_Prisoner[2]))

You Want:

JASS:
call IssuePointOrderLoc( udg_Unit_Guard_Prisoner[1], "move", GetUnitLoc(udg_Unit_Guard_Prisoner[2]) )

Just a note: Native function sometimes take the peramitters in a different order.
 
Level 5
Joined
Dec 10, 2007
Messages
65
Trigger Overhaul - missing the point

Im sorry to sound rude at all, but I am new to jass so i dont know a great deal about it. I have looked at the tutorials posted up, but i think they are a load of crap and dont tell me anything new that i havent learnt already in java.

To what I was saying, changing a BJ function to a native function sounds like just word manipulation (i.e. solving a small leak in a trigger). This is all well and good for fixing small problems, but I need a trigger overhaul.

i.e. I need someone to look at what I have written in my first post to code up a fresh new version of the trigger from scrap in jass who know what they are doing. Me attempting to change small variations of my existing trigger (which originally came from GUI) isn't going to solve my problem because the GUI wasn't working in the first place.

I dont want to sound like a whiney ungrateful little bitch, but can someone please look at my trigger expectations laid out in my first post (before the GUI coding) and code up something in jass to help me with this problem? Any help given will result in +rep.

EDIT - I havent seen the tutorials of jass yet i just realized, but the jass classroom. My apologies, and starting to read through it now.
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
Best JASS tutorial: just try making stuff with JassCraft.
You can download it here.

[Tip] never type your codes in the normal WE ! it crashes a lot of times without any reason and voila... your code just went to hell unless you saved it 1 second before (or unless it was a pure white code which will send it to heaven ! :D).

Another Tip Instead of all those blizzard conditions, for example
Code:
function Trig_prisoner_loop_checker_1_Func003C takes nothing returns boolean
    if ( not ( udg_GuardDistance <= 500.00 ) ) then
        return false
    endif
    return true
endfunction

You can just type it like this
Code:
function Trig_prisoner_loop_checker_1_Func003C takes nothing returns boolean
    return udg_GuardDistance <= 500.00
endfunction
 
Level 11
Joined
Aug 25, 2006
Messages
971
Best JASS tutorial: just try making stuff with JassCraft.
You can download it here.

[Tip] never type your codes in the normal WE ! it crashes a lot of times without any reason and voila... your code just went to hell unless you saved it 1 second before (or unless it was a pure white code which will send it to heaven ! :D).
lol? Ever heard of Jass New Gen Editor? It replaces WE's crappy syntax checker with a much better one. It also adds syntax highlighting and has a function finder. Its almost exactly like Jasscraft except its in WE.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
lol? Ever heard of Jass New Gen Editor? It replaces WE's crappy syntax checker with a much better one. It also adds syntax highlighting and has a function finder. Its almost exactly like Jasscraft except its in WE.


Tried using it, I got really confused. But maybe that's because it was before I even started writing in JASS ? :huh:

Anyway, im really happy with JassCraft at the moment.

WE's crappy syntax checker

So funny (and sad) to get 200+ compile errors because a single not-even-syntax-error ^^
 
Status
Not open for further replies.
Top