• 🏆 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!

[Trigger] Easiest Trigger for Ally/Unally? [Need Help]

Status
Not open for further replies.
Level 7
Joined
Apr 3, 2009
Messages
317
Whats the easiest trigger for ally/unally?
The quickest and most effective?
Thanks :)
I do know how to do it HOWEVER, it takes me ages and ages! A few hours.. I'm sure there are alot of much more faster ways than the way I do it! Please help! :thumbs_up:
 
Level 7
Joined
Apr 3, 2009
Messages
317
  • Player - Make <Player> treat <Player> as an Ally with shared vision // ally
  • Player - Make <Player> treat <Player> as an Enemy // "unally"

I don't really understand what that means.. :x.. I know thats the trigger but can you put some more info into it, thanks :grin:
 
Level 9
Joined
Jun 25, 2009
Messages
427
These things are simple, but DON'T forget to make it to the both sides, look what i mean.
  • Actions:
    • Player - Make (Player 1) treat (Player 2) as Enemy
    • Player - Make (Player 2) treat (Player 1) as Enemy
Because it can ruin if you do it like player 1 treat player 2 ally and the player 2 still treats you as an enemy and to you he's ally ;)
 
Level 8
Joined
Nov 21, 2008
Messages
316
THis should be fairly easy to understand
  • Setting Up Triggers
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Actual Trigger <gen> the event (Player - (Picked player) types a chat message containing -Ally as A substring)
          • Trigger - Add to War <gen> the event (Player - (Picked player) types a chat message containing -War as A substring)
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = red
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = blue
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = teal
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = purple
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = yellow
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = orange
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = green
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = pink
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = gray
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = light blue
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = dark green
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = brown
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
Then make this
  • Actual Trigger
    • Events
    • Conditions
    • Actions
      • Set playergroups[0] = (All players matching (((Matching player) slot status) Equal to Is playing))
      • Set playergroups[1] = (All players matching (((Triggering player) is an ally of (Matching player)) Equal to True))
      • Set playergroups[2] = (All players matching ((((Matching player) is in playergroups[0]) Equal to True) and (((Matching player) is in playergroups[1]) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in playergroups[2]) Less than alliancesize
        • Then - Actions
          • For each (Integer A) from 1 to 12, do (Actions)
            • Loop - Actions
              • Set playergroups[1] = (All allies of (Player((Integer A))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Substring((Entered chat string), 7, (Length of (Entered chat string)))) Equal to AllyStringColor[(Integer A)]
                • Then - Actions
                  • Player - Make (Triggering player) treat (Player((Integer A))) as an Ally with shared vision
                • Else - Actions
              • Custom script: call DestroyForce( udg_playergroups[1] )
        • Else - Actions
          • Set playergroups[3] = (Player group((Triggering player)))
          • Game - Display to playergroups[3] the text: You already have al...
          • Custom script: call DestroyForce( udg_playergroups[3] )
      • Custom script: call DestroyForce( udg_playergroups[0] )
      • Custom script: call DestroyForce( udg_playergroups[1] )
      • Custom script: call DestroyForce( udg_playergroups[2] )
And Finally this

  • War
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to AllyStringColor[(Integer A)]
            • Then - Actions
              • Player - Make (Triggering player) treat (Player((Integer A))) as an Enemy
              • Player - Make (Player((Integer A))) treat (Triggering player) as an Enemy
            • Else - Actions
Its made so there is no room for fagery... if one player wars his ally the alliance automatically ends. That way the other player doesnt have to type -war color to start fighting the bastered who wared him.
 
Level 4
Joined
Jul 11, 2007
Messages
82
I think this is more what he wants. This will allow players to use -ally, -unally, -war, -neutral, or -na to ally, unally, unally, neutral, or neutral another player. It also displays messages to say what happened. Those could be removed. Also, if one player unallies another, the other AUTOMATICALLY declares war back. You could change this if you wanted. Main credit to PurplePoot because he wrote this for me and I only changed some things to make it fit my map.

JASS:
scope Diplomacy initializer init

function SetAllianceState takes string s, integer allianceType returns integer
    local integer playerhelper = 0
    local integer aid = 0
    set s = StringCase(s,false)
    if s=="red" then
        set aid = 1
    elseif s=="blue" then
        set aid = 2
    elseif s=="teal" then
        set aid = 3
    elseif s=="purple" then
        set aid = 4
    elseif s=="yellow" then
        set aid = 5
    elseif s=="orange" or s=="oj" then
        set aid = 6
    elseif s=="green" then
        set aid = 7
    elseif s=="pink" then
        set aid = 8
    elseif s=="gray" then
        set aid = 9
    elseif s=="light blue" or s=="lightblue" or s=="lb" then
        set aid = 10
    elseif s=="darkgreen" or s=="dark green" or s=="dg" then
        set aid = 11
    elseif s=="brown" then
        set aid = 12
    endif
    if aid == 0 then
        return 0
    endif
    call SetPlayerAllianceStateBJ(GetTriggerPlayer(),Player(aid-1),allianceType)
    return aid
endfunction

private function UnallyActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),8,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_UNALLIED)
    local integer id = aid
    if id == 0 then
        return
    endif
    call SetPlayerAllianceStateBJ(Player(id-1),GetTriggerPlayer(),bj_ALLIANCE_UNALLIED)
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00has expressed hostility towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function WarActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),5,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_UNALLIED)
    local integer id = aid
    if id == 0 then
        return
    endif
    call SetPlayerAllianceStateBJ(Player(id-1),GetTriggerPlayer(),bj_ALLIANCE_UNALLIED)
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00has expressed hostility towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function NeutActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),9,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_NEUTRAL)
    local integer id = aid
    if id == 0 then
        return
    endif
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00is showing neutrality towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function NAActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),4,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_NEUTRAL)
    local integer id = aid
    if id == 0 then
        return
    endif
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00is showing neutrality towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function AllyActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),6,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_ALLIED_VISION)
    local integer id = aid
    if id == 0 then
        return
    endif
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00has allied|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function init takes nothing returns nothing
    local trigger a = CreateTrigger()
    local trigger u = CreateTrigger()
    local trigger w = CreateTrigger()
    local trigger n = CreateTrigger()
    local trigger na = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i > 11
        call TriggerRegisterPlayerChatEvent(a,Player(i),"-ally ",false)
        call TriggerRegisterPlayerChatEvent(u,Player(i),"-unally ",false)
        call TriggerRegisterPlayerChatEvent(w,Player(i),"-war ",false)
        call TriggerRegisterPlayerChatEvent(n,Player(i),"-neutral ",false)
        call TriggerRegisterPlayerChatEvent(na,Player(i),"-na ",false)
        set i = i + 1
    endloop
    call TriggerAddAction(a,function AllyActions)
    call TriggerAddAction(u,function UnallyActions)
    call TriggerAddAction(w,function WarActions)
    call TriggerAddAction(n,function NeutActions)
    call TriggerAddAction(na,function NAActions)
endfunction

endscope

Hopefully it works, but if it doesn't, I or someone else can try to help you.
 
Level 7
Joined
Apr 3, 2009
Messages
317
I think this is more what he wants. This will allow players to use -ally, -unally, -war, -neutral, or -na to ally, unally, unally, neutral, or neutral another player. It also displays messages to say what happened. Those could be removed. Also, if one player unallies another, the other AUTOMATICALLY declares war back. You could change this if you wanted. Main credit to PurplePoot because he wrote this for me and I only changed some things to make it fit my map.

JASS:
scope Diplomacy initializer init

function SetAllianceState takes string s, integer allianceType returns integer
    local integer playerhelper = 0
    local integer aid = 0
    set s = StringCase(s,false)
    if s=="red" then
        set aid = 1
    elseif s=="blue" then
        set aid = 2
    elseif s=="teal" then
        set aid = 3
    elseif s=="purple" then
        set aid = 4
    elseif s=="yellow" then
        set aid = 5
    elseif s=="orange" or s=="oj" then
        set aid = 6
    elseif s=="green" then
        set aid = 7
    elseif s=="pink" then
        set aid = 8
    elseif s=="gray" then
        set aid = 9
    elseif s=="light blue" or s=="lightblue" or s=="lb" then
        set aid = 10
    elseif s=="darkgreen" or s=="dark green" or s=="dg" then
        set aid = 11
    elseif s=="brown" then
        set aid = 12
    endif
    if aid == 0 then
        return 0
    endif
    call SetPlayerAllianceStateBJ(GetTriggerPlayer(),Player(aid-1),allianceType)
    return aid
endfunction

private function UnallyActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),8,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_UNALLIED)
    local integer id = aid
    if id == 0 then
        return
    endif
    call SetPlayerAllianceStateBJ(Player(id-1),GetTriggerPlayer(),bj_ALLIANCE_UNALLIED)
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00has expressed hostility towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function WarActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),5,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_UNALLIED)
    local integer id = aid
    if id == 0 then
        return
    endif
    call SetPlayerAllianceStateBJ(Player(id-1),GetTriggerPlayer(),bj_ALLIANCE_UNALLIED)
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00has expressed hostility towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function NeutActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),9,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_NEUTRAL)
    local integer id = aid
    if id == 0 then
        return
    endif
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00is showing neutrality towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function NAActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),4,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_NEUTRAL)
    local integer id = aid
    if id == 0 then
        return
    endif
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00is showing neutrality towards|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function AllyActions takes nothing returns nothing
    local integer aid = SetAllianceState(SubString(GetEventPlayerChatString(),6,StringLength(GetEventPlayerChatString())),bj_ALLIANCE_ALLIED_VISION)
    local integer id = aid
    if id == 0 then
        return
    endif
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0.,0.,30.,GetPlayerName(GetTriggerPlayer())+" |cffffcc00has allied|r "+GetPlayerName(Player(id+1))+"|cffffcc00.|r")
endfunction

private function init takes nothing returns nothing
    local trigger a = CreateTrigger()
    local trigger u = CreateTrigger()
    local trigger w = CreateTrigger()
    local trigger n = CreateTrigger()
    local trigger na = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i > 11
        call TriggerRegisterPlayerChatEvent(a,Player(i),"-ally ",false)
        call TriggerRegisterPlayerChatEvent(u,Player(i),"-unally ",false)
        call TriggerRegisterPlayerChatEvent(w,Player(i),"-war ",false)
        call TriggerRegisterPlayerChatEvent(n,Player(i),"-neutral ",false)
        call TriggerRegisterPlayerChatEvent(na,Player(i),"-na ",false)
        set i = i + 1
    endloop
    call TriggerAddAction(a,function AllyActions)
    call TriggerAddAction(u,function UnallyActions)
    call TriggerAddAction(w,function WarActions)
    call TriggerAddAction(n,function NeutActions)
    call TriggerAddAction(na,function NAActions)
endfunction

endscope

Hopefully it works, but if it doesn't, I or someone else can try to help you.

Thanks alot.. but where do I put it? Do I need to use my jass editor? Or do I go to triggers and click the name of my map at the top right of the trigger editor?
+Rep

THis should be fairly easy to understand
  • Setting Up Triggers
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Actual Trigger <gen> the event (Player - (Picked player) types a chat message containing -Ally as A substring)
          • Trigger - Add to War <gen> the event (Player - (Picked player) types a chat message containing -War as A substring)
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = red
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = blue
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = teal
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = purple
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = yellow
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = orange
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = green
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = pink
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = gray
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = light blue
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = dark green
      • Set Integer = (Integer + 1)
      • Set AllyStringColor[Integer] = brown
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
Then make this
  • Actual Trigger
    • Events
    • Conditions
    • Actions
      • Set playergroups[0] = (All players matching (((Matching player) slot status) Equal to Is playing))
      • Set playergroups[1] = (All players matching (((Triggering player) is an ally of (Matching player)) Equal to True))
      • Set playergroups[2] = (All players matching ((((Matching player) is in playergroups[0]) Equal to True) and (((Matching player) is in playergroups[1]) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in playergroups[2]) Less than alliancesize
        • Then - Actions
          • For each (Integer A) from 1 to 12, do (Actions)
            • Loop - Actions
              • Set playergroups[1] = (All allies of (Player((Integer A))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Substring((Entered chat string), 7, (Length of (Entered chat string)))) Equal to AllyStringColor[(Integer A)]
                • Then - Actions
                  • Player - Make (Triggering player) treat (Player((Integer A))) as an Ally with shared vision
                • Else - Actions
              • Custom script: call DestroyForce( udg_playergroups[1] )
        • Else - Actions
          • Set playergroups[3] = (Player group((Triggering player)))
          • Game - Display to playergroups[3] the text: You already have al...
          • Custom script: call DestroyForce( udg_playergroups[3] )
      • Custom script: call DestroyForce( udg_playergroups[0] )
      • Custom script: call DestroyForce( udg_playergroups[1] )
      • Custom script: call DestroyForce( udg_playergroups[2] )
And Finally this

  • War
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to AllyStringColor[(Integer A)]
            • Then - Actions
              • Player - Make (Triggering player) treat (Player((Integer A))) as an Enemy
              • Player - Make (Player((Integer A))) treat (Triggering player) as an Enemy
            • Else - Actions
Its made so there is no room for fagery... if one player wars his ally the alliance automatically ends. That way the other player doesnt have to type -war color to start fighting the bastered who wared him.

+Rep to you also
 
Level 4
Joined
Jul 11, 2007
Messages
82
Ok, maybe blackrockorc was right....

All you need to do is create a new trigger and then, with it selected, go to Edit> Convert to Custom Text. You'll see it changed it to JASS and has some stuff there. Delete all of that stuff and then copy and paste all that code into the blank trigger.

But you probably shouldn't do this if you don't use NewGen because if there is an error you may be unable to detect it correctly and then you'll just have a mess.
 
Level 7
Joined
Apr 3, 2009
Messages
317
Ok, maybe blackrockorc was right....

All you need to do is create a new trigger and then, with it selected, go to Edit> Convert to Custom Text. You'll see it changed it to JASS and has some stuff there. Delete all of that stuff and then copy and paste all that code into the blank trigger.

But you probably shouldn't do this if you don't use NewGen because if there is an error you may be unable to detect it correctly and then you'll just have a mess.

Whats NewGen? :x
 
Status
Not open for further replies.
Top