- Joined
- Nov 30, 2007
- Messages
- 1,202
Conditions not working!
JASS:
function Ability_Interact takes nothing returns boolean
local integer idD = GetDestructableTypeId(GetSpellTargetDestructable())
return GetSpellAbilityId() == 'ACfn' and (idD == 'LTe2' or idD == 'LTg1')
endfunction
function Gate_Interaction_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
local destructable TargetedGate = GetSpellTargetDestructable()
local real x = GetLocationX(GetRectCenter(gg_rct_Options_Spawn))
local real y = GetLocationY(GetRectCenter(gg_rct_Options_Spawn))
local integer PlayerNum = GetConvertedPlayerId(p)
local integer GateArray
local integer i = 0
set udg_InteractionCurrentTarget_d[PlayerNum] = TargetedGate
loop
exitwhen i > udg_GateCount
if (udg_Gate[i] == TargetedGate) then
set GateArray = i
set i = udg_GateCount + 1
else
set i = i + 1
endif
endloop
// Abilities: Open - 'A005', Close - 'A006', Lock 'Aslp', Unlock - 'A008', Knock - 'ACwe', Information - 'ACsf'
set udg_InteractionCurrentTarget_i[PlayerNum] = GateArray
set udg_OptionsUnit[PlayerNum] = CreateUnit(p, 'hhou', x, y, 0.00 )
call SelectUnitForPlayerSingle(udg_OptionsUnit[PlayerNum], p)
call UnitAddAbilityBJ('ACsf', udg_OptionsUnit[PlayerNum])
if (udg_GateStatus[GateArray] != 0) then // Status != Dead
call UnitAddAbilityBJ('ACwe', udg_OptionsUnit[PlayerNum])
if (udg_GateStatus[GateArray] == -2) then // Status = Closed and Locked
call UnitAddAbilityBJ('ACwe', udg_OptionsUnit[PlayerNum])
if (IsPlayerInForce(p, udg_GateControl_g[GateArray]) == true ) then //Player has control
call UnitAddAbilityBJ('A005', udg_OptionsUnit[PlayerNum])
call UnitAddAbilityBJ('A008', udg_OptionsUnit[PlayerNum])
endif
endif
if (udg_GateStatus[GateArray] == -1) then // Status = Closed and Unlocked
call UnitAddAbilityBJ('A005', udg_OptionsUnit[PlayerNum])
if (IsPlayerInForce(p, udg_GateControl_g[GateArray]) == true ) then
call UnitAddAbilityBJ('Aslp', udg_OptionsUnit[PlayerNum])
endif
endif
if (udg_GateStatus[GateArray] == 1) then // Status = Open and Locked
if (IsPlayerInForce(p, udg_GateControl_g[GateArray]) == true ) then
call UnitAddAbilityBJ('A006', udg_OptionsUnit[PlayerNum])
call UnitAddAbilityBJ('A008', udg_OptionsUnit[PlayerNum])
endif
endif
if (udg_GateStatus[GateArray] == 2) then // Status = Open and Unlocked
call UnitAddAbilityBJ('A006', udg_OptionsUnit[PlayerNum])
if (IsPlayerInForce(p, udg_GateControl_g[GateArray]) == true ) then
call UnitAddAbilityBJ('Aslp', udg_OptionsUnit[PlayerNum])
endif
endif
endif
set p = null
set TargetedGate = null
endfunction
//===========================================================================
function InitTrig_Gate_Interaction takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerAddCondition(t, Condition(function Ability_Interact))
call TriggerAddAction(t, function Gate_Interaction_Actions)
set t = null
endfunction
JASS:
function CheckForOptionsUnit takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'hhou'
endfunction
function GateSpell_Actions takes nothing returns nothing
local player p = GetTriggerPlayer() // Will probably use it more when I add messages.
local integer i = udg_InteraCurTarget_i[GetConvertedPlayerId(p)]
local destructable Gate = udg_Gate[i]
local destructable GatePathing = udg_GatePathing[i]
local integer PlayerNum = GetConvertedPlayerId(GetTriggerPlayer())
local real y = GetLocationY(GetDestructableLoc(Gate))
local real x = GetLocationX(GetDestructableLoc(Gate))
local integer z = 1
if (udg_GateStatus[i] != 0) then // GateStatus != Broken
if (GetSpellAbilityId() == 'A005') then // Open Gate
call SetDestructableAnimationBJ(Gate, "death alternate")
call SetDestructableInvulnerableBJ(Gate, true)
call KillDestructable(GatePathing)
//Replaces abilities from eveyr player that has it avalible.
loop
exitwhen z > 11
if (udg_InteraCurTarget_d[z] == udg_InteraCurTarget_d[PlayerNum]) then
call UnitRemoveAbilityBJ( 'A005', udg_InteraOptions_u[z])
call UnitAddAbilityBJ( 'A006', udg_InteraOptions_u[z])
endif
set z = z + 1
endloop
//Takes the GateStatus and changes it to matching opposite.
if (udg_GateStatus[i] == -2) then
set udg_GateStatus[i] = 1
else
set udg_GateStatus[i] = 2
endif
endif
if (GetSpellAbilityId() == 'A006') then // Close Gate
call SetDestructableAnimationBJ(Gate, "stand")
call SetDestructableInvulnerableBJ(Gate, false)
call DestructableRestoreLife(GatePathing, 250, true )
loop
exitwhen z > 11
if (udg_InteraCurTarget_d[z] == udg_InteraCurTarget_d[PlayerNum]) then
call UnitRemoveAbilityBJ( 'A006', udg_InteraOptions_u[z])
call UnitAddAbilityBJ( 'A005', udg_InteraOptions_u[z])
endif
set z = z + 1
endloop
if (udg_GateStatus[i] == 1) then
set udg_GateStatus[i] = -2
else
set udg_GateStatus[i] = -1
endif
endif
if (GetSpellAbilityId() == 'Aslp') then // Lock Gate
call PlaySoundAtPointBJ(gg_snd_Lever, 100, Location(x, y), 1500.00)
if (udg_GateStatus[i] == -1 ) then // GateStatus = Closed and Unlocked
set udg_GateStatus[i] = -2
else
set udg_GateStatus[i] = 1
endif
loop
exitwhen z > 11
if (udg_InteraCurTarget_d[z] == udg_InteraCurTarget_d[PlayerNum]) then
call UnitRemoveAbilityBJ( 'Aslp', udg_InteraOptions_u[z])
call UnitAddAbilityBJ( 'A008', udg_InteraOptions_u[z])
endif
set z = z + 1
endloop
endif
if (GetSpellAbilityId() == 'A008') then // Unlock Gate
call PlaySoundAtPointBJ(gg_snd_Lever, 100, Location(x, y), 1500.00)
if (udg_GateStatus[i] == -2) then // GateStatus = Closed and Unlocked
set udg_GateStatus[i] = -1
else
set udg_GateStatus[i] = 2
endif
loop
exitwhen z > 11
if (udg_InteraCurTarget_d[z] == udg_InteraCurTarget_d[PlayerNum]) then
call UnitRemoveAbilityBJ( 'A008', udg_InteraOptions_u[z])
call UnitAddAbilityBJ( 'Aslp', udg_InteraOptions_u[z])
endif
set z = z + 1
endloop
endif
if (GetSpellAbilityId() == 'ACwe') then // Knock On Gate
if ((udg_GateOwner[i] != Player(11)) and (udg_GateOwner[i] == p)) then
call PingMinimapLocForForceEx( GetForceOfPlayer(udg_GateOwner[i]), Location(x, y), 4.00, bj_MINIMAPPINGSTYLE_SIMPLE, 100, 100, 100)
call DisplayTextToForce(GetForceOfPlayer(udg_GateOwner[i]), "Alert: Someone is knocking on your door...")
endif
call PlaySoundAtPointBJ(gg_snd_DoorKnock, 100, Location(x, y), 1500.00)
call TriggerSleepAction(0.25)
call PlaySoundAtPointBJ(gg_snd_DoorKnock, 100, Location(x, y), 1500.00)
call TriggerSleepAction(0.25)
call PlaySoundAtPointBJ(gg_snd_DoorKnock, 100, Location(x, y), 1500.00)
call TriggerSleepAction(0.25)
endif
endif
set p = null
set Gate = null
set GatePathing = null
endfunction
//===========================================================================
function InitTrig_Gate_Spells takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerAddCondition(t, Condition( function CheckForOptionsUnit))
call TriggerAddAction(t, function GateSpell_Actions)
set t = null
endfunction
Last edited: