• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!

plz check my system

Status
Not open for further replies.
Level 7
Joined
Feb 14, 2008
Messages
289
I want to know if this trigger works properly.
  • Events
    • Unit - A unit Is attacked
  • Conditions
    • (Unit-type of (Attacked unit)) Equal to Main_Hall_Type
    • (Life of (Attacked unit)) Less than or equal to 1000.00
    • (Owner of (Attacked unit)) Equal to Player 1 (Red)
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Color of (Owner of (Attacking unit))) Equal to Blue
      • Then - Actions
        • Unit - Set life of Mainhall[1] to 100.00%
        • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
        • Player Group - Add Player 1 (Red) to Empire[2]
        • Player Group - Pick every player in Empire[2] and do (Actions)
          • Loop - Actions
            • Player Group - Make Empire[2] treat (All players) as an Enemy
            • Player Group - Make Empire[2] treat Empire[2] as an Ally with shared vision
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Color of (Owner of (Attacking unit))) Equal to Teal
          • Then - Actions
            • Unit - Set life of Mainhall[1] to 100.00%
            • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
            • Player Group - Add Player 1 (Red) to Empire[3]
            • Player Group - Pick every player in Empire[3] and do (Actions)
              • Loop - Actions
                • Player Group - Make Empire[3] treat (All players) as an Enemy
                • Player Group - Make Empire[3] treat Empire[3] as an Ally with shared vision
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Color of (Owner of (Attacking unit))) Equal to Purple
              • Then - Actions
                • Unit - Set life of Mainhall[1] to 100.00%
                • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
                • Player Group - Add Player 1 (Red) to Empire[4]
                • Player Group - Pick every player in Empire[4] and do (Actions)
                  • Loop - Actions
                    • Player Group - Make Empire[4] treat (All players) as an Enemy
                    • Player Group - Make Empire[4] treat Empire[4] as an Ally with shared vision
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Color of (Owner of (Attacking unit))) Equal to Yellow
                  • Then - Actions
                    • Unit - Set life of Mainhall[1] to 100.00%
                    • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
                    • Player Group - Add Player 1 (Red) to Empire[5]
                    • Player Group - Pick every player in Empire[5] and do (Actions)
                      • Loop - Actions
                        • Player Group - Make Empire[5] treat (All players) as an Enemy
                        • Player Group - Make Empire[5] treat Empire[5] as an Ally with shared vision
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (Color of (Owner of (Attacking unit))) Equal to Orange
                      • Then - Actions
                        • Unit - Set life of Mainhall[1] to 100.00%
                        • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
                        • Player Group - Add Player 1 (Red) to Empire[6]
                        • Player Group - Pick every player in Empire[6] and do (Actions)
                          • Loop - Actions
                            • Player Group - Make Empire[6] treat (All players) as an Enemy
                            • Player Group - Make Empire[6] treat Empire[6] as an Ally with shared vision
                      • Else - Actions
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • (Color of (Owner of (Attacking unit))) Equal to Green
                          • Then - Actions
                            • Unit - Set life of Mainhall[1] to 100.00%
                            • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
                            • Player Group - Add Player 1 (Red) to Empire[7]
                            • Player Group - Pick every player in Empire[7] and do (Actions)
                              • Loop - Actions
                                • Player Group - Make Empire[7] treat (All players) as an Enemy
                                • Player Group - Make Empire[7] treat Empire[7] as an Ally with shared vision
                          • Else - Actions
                            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • If - Conditions
                                • (Color of (Owner of (Attacking unit))) Equal to Pink
                              • Then - Actions
                                • Unit - Set life of Mainhall[1] to 100.00%
                                • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
                                • Player Group - Add Player 1 (Red) to Empire[8]
                                • Player Group - Pick every player in Empire[8] and do (Actions)
                                  • Loop - Actions
                                    • Player Group - Make Empire[8] treat (All players) as an Enemy
                                    • Player Group - Make Empire[8] treat Empire[8] as an Ally with shared vision
                              • Else - Actions
                                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                  • If - Conditions
                                    • (Color of (Owner of (Attacking unit))) Equal to Gray
                                  • Then - Actions
                                    • Unit - Set life of Mainhall[1] to 100.00%
                                    • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
                                    • Player Group - Add Player 1 (Red) to Empire[9]
                                    • Player Group - Pick every player in Empire[9] and do (Actions)
                                      • Loop - Actions
                                        • Player Group - Make Empire[9] treat (All players) as an Enemy
                                        • Player Group - Make Empire[9] treat Empire[9] as an Ally with shared vision
                                  • Else - Actions
                                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                      • If - Conditions
                                        • (Color of (Owner of (Attacking unit))) Equal to Light Blue
                                      • Then - Actions
                                        • Unit - Set life of Mainhall[1] to 100.00%
                                        • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
                                        • Player Group - Add Player 1 (Red) to Empire[10]
                                        • Player Group - Pick every player in Empire[10] and do (Actions)
                                          • Loop - Actions
                                            • Player Group - Make Empire[10] treat (All players) as an Enemy
                                            • Player Group - Make Empire[10] treat Empire[10] as an Ally with shared vision
                                      • Else - Actions
                                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                          • If - Conditions
                                            • (Color of (Owner of (Attacking unit))) Equal to Dark Green
                                          • Then - Actions
                                            • Unit - Set life of Mainhall[1] to 100.00%
                                            • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
                                            • Player Group - Add Player 1 (Red) to Empire[11]
                                            • Player Group - Pick every player in Empire[11] and do (Actions)
                                              • Loop - Actions
                                                • Player Group - Make Empire[11] treat (All players) as an Enemy
                                                • Player Group - Make Empire[11] treat Empire[11] as an Ally with shared vision
                                          • Else - Actions
                                            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                              • If - Conditions
                                                • (Color of (Owner of (Attacking unit))) Equal to Brown
                                              • Then - Actions
                                                • Unit - Set life of Mainhall[1] to 100.00%
                                                • Player - Change color of Player 1 (Red) to (Color of (Owner of (Attacking unit))), Changing color of existing units
                                                • Player Group - Add Player 1 (Red) to Empire[12]
                                                • Player Group - Pick every player in Empire[12] and do (Actions)
                                                  • Loop - Actions
                                                    • Player Group - Make Empire[12] treat (All players) as an Enemy
                                                    • Player Group - Make Empire[12] treat Empire[12] as an Ally with shared vision
                                              • Else - Actions
                                                • Do nothing
what i want is this. when the main building, townhall basicly, reaches 1k hp, the color of everything that player owns is changed to the same color as the one who attacked. he allys the attaker, and allys all the attakers allys also.

while unallying everyhing else, even his previous allys.
 
I don't know if its right since I only know the jass actions..

  • set tmp_int = GetPlayerNumber(Owner of (Attacking unit)))
  • Unit - Set life of Mainhall[ tmp_int] to 100.00%
  • Player - Change color of Player(tmp_int) to (Color of (Owner of (Attacking unit))), Changing color of existing units
  • Player Group - Add Player(tmp_int) to Empire[tmp_int]
  • Player Group - Pick every player in Empire[tmp_int] and do (Actions)
  • Loop - Actions
  • Player Group - Make Empire[ tmp_int] treat (All players) as an Enemy
  • Player Group - Make Empire[ tmp_int] treat Empire[tmp_int] as an Ally with shared vision
  • Else - Actions
  • Do nothing
Wouldn't this work?
 
Level 7
Joined
Feb 14, 2008
Messages
289
Alright. then here is a jass copy of what i did. if this trigger works, then plz just say so. i dont want to have to fix something that isnt broken.

JASS:
function Trig_ally_unally_red_Copy_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetAttackedUnitBJ()) == udg_Main_Hall_Type ) ) then
        return false
    endif
    if ( not ( GetUnitStateSwap(UNIT_STATE_LIFE, GetAttackedUnitBJ()) <= 1000.00 ) ) then
        return false
    endif
    if ( not ( GetOwningPlayer(GetAttackedUnitBJ()) == Player(0) ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[12], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[12], udg_Empire[12], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_BROWN ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[11], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[11], udg_Empire[11], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_AQUA ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[10], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[10], udg_Empire[10], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_LIGHT_BLUE ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[9], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[9], udg_Empire[9], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_LIGHT_GRAY ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[8], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[8], udg_Empire[8], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_PINK ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[7], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[7], udg_Empire[7], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_GREEN ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[6], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[6], udg_Empire[6], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_ORANGE ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[5], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[5], udg_Empire[5], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_YELLOW ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[4], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[4], udg_Empire[4], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_PURPLE ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[3], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[3], udg_Empire[3], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_CYAN ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Func001Func005A takes nothing returns nothing
    call SetForceAllianceStateBJ( udg_Empire[2], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[2], udg_Empire[2], bj_ALLIANCE_ALLIED_VISION )
endfunction

function Trig_ally_unally_red_Copy_Func001C takes nothing returns boolean
    if ( not ( GetPlayerColor(GetOwningPlayer(GetAttacker())) == PLAYER_COLOR_BLUE ) ) then
        return false
    endif
    return true
endfunction

function Trig_ally_unally_red_Copy_Actions takes nothing returns nothing
    if ( Trig_ally_unally_red_Copy_Func001C() ) then
        call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
        call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
        call ForceAddPlayerSimple( Player(0), udg_Empire[2] )
        call ForForce( udg_Empire[2], function Trig_ally_unally_red_Copy_Func001Func005A )
    else
        if ( Trig_ally_unally_red_Copy_Func001Func001C() ) then
            call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
            call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
            call ForceAddPlayerSimple( Player(0), udg_Empire[3] )
            call ForForce( udg_Empire[3], function Trig_ally_unally_red_Copy_Func001Func001Func005A )
        else
            if ( Trig_ally_unally_red_Copy_Func001Func001Func001C() ) then
                call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
                call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
                call ForceAddPlayerSimple( Player(0), udg_Empire[4] )
                call ForForce( udg_Empire[4], function Trig_ally_unally_red_Copy_Func001Func001Func001Func005A )
            else
                if ( Trig_ally_unally_red_Copy_Func001Func001Func001Func001C() ) then
                    call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
                    call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
                    call ForceAddPlayerSimple( Player(0), udg_Empire[5] )
                    call ForForce( udg_Empire[5], function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func005A )
                else
                    if ( Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001C() ) then
                        call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
                        call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
                        call ForceAddPlayerSimple( Player(0), udg_Empire[6] )
                        call ForForce( udg_Empire[6], function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func005A )
                    else
                        if ( Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001C() ) then
                            call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
                            call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
                            call ForceAddPlayerSimple( Player(0), udg_Empire[7] )
                            call ForForce( udg_Empire[7], function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func005A )
                        else
                            if ( Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001C() ) then
                                call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
                                call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
                                call ForceAddPlayerSimple( Player(0), udg_Empire[8] )
                                call ForForce( udg_Empire[8], function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func005A )
                            else
                                if ( Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001C() ) then
                                    call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
                                    call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
                                    call ForceAddPlayerSimple( Player(0), udg_Empire[9] )
                                    call ForForce( udg_Empire[9], function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func005A )
                                else
                                    if ( Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001C() ) then
                                        call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
                                        call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
                                        call ForceAddPlayerSimple( Player(0), udg_Empire[10] )
                                        call ForForce( udg_Empire[10], function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func005A )
                                    else
                                        if ( Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001C() ) then
                                            call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
                                            call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
                                            call ForceAddPlayerSimple( Player(0), udg_Empire[11] )
                                            call ForForce( udg_Empire[11], function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001Func005A )
                                        else
                                            if ( Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001C() ) then
                                                call SetUnitLifePercentBJ( udg_Mainhall[1], 100 )
                                                call SetPlayerColorBJ( Player(0), GetPlayerColor(GetOwningPlayer(GetAttacker())), true )
                                                call ForceAddPlayerSimple( Player(0), udg_Empire[12] )
                                                call ForForce( udg_Empire[12], function Trig_ally_unally_red_Copy_Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001Func001Func005A )
                                            else
                                                call DoNothing(  )
                                            endif
                                        endif
                                    endif
                                endif
                            endif
                        endif
                    endif
                endif
            endif
        endif
    endif
endfunction

//===========================================================================
function InitTrig_ally_unally_red_Copy takes nothing returns nothing
    set gg_trg_ally_unally_red_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ally_unally_red_Copy, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_ally_unally_red_Copy, Condition( function Trig_ally_unally_red_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_ally_unally_red_Copy, function Trig_ally_unally_red_Copy_Actions )
endfunction
 
I am optimizing it... It will take a bit. Please wait.

edit:

JASS:
function Condition takes nothing returns boolean
if GetUnitTypeId(GetAttackedUnitBJ()) == udg_Main_Hall_Type and GetUnitStateSwap(UNIT_STATE_LIFE, GetAttackedUnitBJ()) <= 1000.00 then
        return true
    endif
    return false
endfunction

function Actions takes nothing returns nothing
set unit a = GetAttacker()
set unit u = GetTriggerUnit()
set player p = GetOwningPlayer(u)
set integer i = GetConvertedPlayerId(p)
call SetUnitLifePercentBJ( udg_Mainhall[i], 100 )
call SetPlayerColorBJ( Player(i), GetPlayerColor(GetOwningPlayer(a), true )
call ForceAddPlayerSimple( Player(i), udg_Empire[i] )

call SetForceAllianceStateBJ( udg_Empire[i], GetPlayersAll(), bj_ALLIANCE_UNALLIED )
call SetForceAllianceStateBJ( udg_Empire[i], udg_Empire[i], bj_ALLIANCE_ALLIED_VISION )
    
endfunction

//===========================================================================
function InitTrig_ally_unally_red_Copy takes nothing returns nothing
    local trigger trig_Ally = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig_Ally, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( trig_Ally, Condition( function Condition() )
    call TriggerAddAction( trig_Ally, function Actions )

set trig_Ally = null
endfunction

this is the code, but because I have written it out of the head (because I am at work) I can't guarantee it to work proberly. Sorry.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Why are you writing jass out of your head using BJ functions?

Further optimisation & error correction:
JASS:
function Condition takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == udg_Main_Hall_Type and GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE) <= 1000.00
endfunction

function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local player offender = GetOwningPlayer(GetAttacker())
    local integer playerid = GetPlayerId(p) + 1 // for gui's sake, let's just keep this +1

    call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE))
    call SetPlayerColor( p, GetPlayerColor(offender, true )
    call ForceAddPlayer(udg_Empire[playerid], offender )
    call SetForceAllianceStateBJ( udg_Empire[playerid], bj_FORCE_ALL_PLAYERS, bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[playerid], udg_Empire[playerid], bj_ALLIANCE_ALLIED_VISION )
    set u = null
    set p = null
    set offender = null
endfunction

//===========================================================================
function InitTrig_ally_unally_red_Copy takes nothing returns nothing
    local trigger trig_Ally = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig_Ally, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( trig_Ally, Condition( function Condition )
    call TriggerAddAction( trig_Ally, function Actions )
endfunction
 
Why are you writing jass out of your head using BJ functions?
I just copied the Actions...

Further optimisation & error correction:
JASS:
function Condition takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == udg_Main_Hall_Type and GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE) <= 1000.00
endfunction

function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local player offender = GetOwningPlayer(GetAttacker())
    local integer playerid = GetPlayerId(p) + 1 // for gui's sake, let's just keep this +1

    call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE))
    call SetPlayerColor( p, GetPlayerColor(offender, true )
    call ForceAddPlayer(udg_Empire[playerid], offender )
    call SetForceAllianceStateBJ( udg_Empire[playerid], bj_FORCE_ALL_PLAYERS, bj_ALLIANCE_UNALLIED )
    call SetForceAllianceStateBJ( udg_Empire[playerid], udg_Empire[playerid], bj_ALLIANCE_ALLIED_VISION )
    set u = null
    set p = null
    set offender = null
endfunction

//===========================================================================
function InitTrig_ally_unally_red_Copy takes nothing returns nothing
    local trigger trig_Ally = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig_Ally, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( trig_Ally, Condition( function Condition )
    call TriggerAddAction( trig_Ally, function Actions )
endfunction
Why do you not delete the trigger variable?
 
Level 7
Joined
Feb 14, 2008
Messages
289
ok. i will add it. but if there is a problem i wont be able to fix it since i dont understand it. and did u make it work for all players? cuz the only player i had be affected by it at the moment was red. but i want all players to join their attacker's team. did u set it that way?

edit: plz convert that to gui... i tried copying it to jass and there were problems...
 
Status
Not open for further replies.
Top