Trigger doesn't change alliance

Charapanga

New Member
Reaction score
46
JASS:
scope Trigger initializer Init

globals
    private constant integer ZombieId = 'nzom'
    // Unit id of the zombie
    private constant integer MarineId = 'hrif'
    //Unit id of the marine
    private player p 
    private player kp
endglobals

private function UnallyMarine takes nothing returns nothing
    call SetPlayerAllianceStateBJ(p, GetEnumPlayer(), bj_ALLIANCE_UNALLIED)
endfunction

private function AllyZombie takes nothing returns nothing
    call SetPlayerAllianceStateBJ(p, GetEnumPlayer(), bj_ALLIANCE_ALLIED_VISION)
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetDyingUnit()
    local unit ku = GetKillingUnit()
    local location l = GetUnitLoc(u)
    local real x = GetLocationX(l)
    local real y = GetLocationY(l)
    local force f = CreateForce()
    local force zf = CreateForce()
    set p = GetOwningPlayer(u)
    set kp = GetOwningPlayer(ku)
    call ForceEnumAllies(f, p, null)
    call ForceEnumAllies(zf, kp, null)
    if GetUnitTypeId(ku) == ZombieId then
        call CreateUnitAtLoc(p, ZombieId, GetPlayerStartLocationLoc(p), 0)
        call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, GetPlayerName(kp)+" has killed "+GetPlayerName(p)+" and has turned him into a zombie!")
        call ForForce(f, function UnallyMarine)
        call ForForce(zf, function AllyZombie)
    elseif GetUnitTypeId(ku) == MarineId then
        call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, GetPlayerName(kp)+" has killed the zombie "+GetPlayerName(p)+"!")
    endif
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddAction( t, function Actions )
endfunction

endscope


I know there are alot of BJs but..
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
It's funny that you don't use TriggerRegisterAnyUnitEventBJ in an initializer function but use BJ in a trigger action.

I assume you tried to display DebugMsg in UnallyMarine and AllyZombie ?
Try to use that :

JASS:


Also i think (need to test yourself) if the alliance change , the units which are already ordered to attack, don't stop themselves attacking their new allie, and old ennemie.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top