- Joined
- Jul 26, 2008
- Messages
- 1,009
I have a custom victory trigger for my map.
It's pretty simple I think. Every 8 seconds it checks all the Heroes for all the Players and then counts them for their force. So if a hero is on the Blood Pack force it counts them.
Now, if a player dies completely, meaning he's wasted all his extra lives, then his hero is removed and he's given a critter to observe the game. This means when the count for his team is made, he will not be counted.
When the count for all teams except 1 is equal to 0, the game ends and victory or defeat is administered.
The problem is it doesn't work like I want, and goes off rather randomly.
It's pretty simple I think. Every 8 seconds it checks all the Heroes for all the Players and then counts them for their force. So if a hero is on the Blood Pack force it counts them.
Now, if a player dies completely, meaning he's wasted all his extra lives, then his hero is removed and he's given a critter to observe the game. This means when the count for his team is made, he will not be counted.
When the count for all teams except 1 is equal to 0, the game ends and victory or defeat is administered.
The problem is it doesn't work like I want, and goes off rather randomly.
JASS:
scope Victory
globals
private integer BloodPackCount
private integer FangSquadCount
private integer HellHordeCount
private integer CrimsonHuntersCount
private integer VileLegionCount
private integer ChosenVampireCount
private integer The11thCount
endglobals
private function CheckEm takes nothing returns boolean
if IsUnitInForce(GetFilterUnit(), BloodPack) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then
set BloodPackCount = BloodPackCount + 1
elseif IsUnitInForce(GetFilterUnit(), FangSquad) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then
set FangSquadCount = FangSquadCount + 1
elseif IsUnitInForce(GetFilterUnit(), HellHorde) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then
set HellHordeCount = HellHordeCount + 1
elseif IsUnitInForce(GetFilterUnit(), CrimsonHunters) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then
set CrimsonHuntersCount = CrimsonHuntersCount + 1
elseif IsUnitInForce(GetFilterUnit(), VileLegion) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then
set VileLegionCount = VileLegionCount + 1
elseif IsUnitInForce(GetFilterUnit(), ChosenVampire) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then
set ChosenVampireCount = ChosenVampireCount + 1
elseif IsUnitInForce(GetFilterUnit(), The11th) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then
set The11thCount = The11thCount + 1
endif
return false
endfunction
public function CheckForces takes nothing returns nothing
set BloodPackCount = 0
set FangSquadCount = 0
set HellHordeCount = 0
set CrimsonHuntersCount = 0
set VileLegionCount = 0
set ChosenVampireCount = 0
set The11thCount = 0
call GroupEnumUnitsOfPlayer(ENUM_GROUP, GetLocalPlayer(), function CheckEm)
// call GroupEnumUnitsInRect(ENUM_GROUP, bj_mapInitialPlayableArea, function CheckEm)
if The11thCount > 0 and FangSquadCount == 0 and BloodPackCount == 0 and HellHordeCount == 0 and CrimsonHuntersCount == 0 and VileLegionCount == 0 and ChosenVampireCount == 0 then
if not IsUnitType(Lieutenant, UNIT_TYPE_DEAD) then
call DisplayTextToForce(The11th, "You are Victorious! Prague is now safe from the Vampire clans.")
else
call DisplayTextToForce(The11th, "You are Victorious! Prague is now under the control of a new Vampire.")
endif
if IsPlayerInForce(GetLocalPlayer(), The11th) then
call CustomVictoryBJ( GetLocalPlayer(), true, true )
else
call CustomDefeatBJ( GetLocalPlayer(), " You have met an unfortunate end.")
endif
elseif BloodPackCount > 0 and FangSquadCount == 0 and HellHordeCount == 0 and CrimsonHuntersCount == 0 and VileLegionCount == 0 and The11thCount == 0 and ChosenVampireCount == 0 then
call DisplayTextToForce(BloodPack, "You are Victorious! The Blood Pack reigns supreme.")
if IsPlayerInForce(GetLocalPlayer(), BloodPack) then
call CustomVictoryBJ( GetLocalPlayer(), true, true )
else
call CustomDefeatBJ(GetLocalPlayer(), " You have met an unfortunate end, along with your clan.")
endif
elseif FangSquadCount > 0 and BloodPackCount == 0 and HellHordeCount == 0 and CrimsonHuntersCount == 0 and VileLegionCount == 0 and ChosenVampireCount == 0 and The11thCount == 0 then
call DisplayTextToForce(FangSquad, "You are Victorious! The Fang Squad reigns supreme.")
if IsPlayerInForce(GetLocalPlayer(), FangSquad) then
call CustomVictoryBJ( GetLocalPlayer(), true, true )
else
call CustomDefeatBJ(GetLocalPlayer(), " You have met an unfortunate end, along with your clan.")
endif
elseif HellHordeCount > 0 and BloodPackCount == 0 and FangSquadCount == 0 and CrimsonHuntersCount == 0 and VileLegionCount == 0 and ChosenVampireCount == 0 and The11thCount == 0 then
call DisplayTextToForce(BloodPack, "You are Victorious! The Hell Horde reigns supreme.")
if IsPlayerInForce(GetLocalPlayer(), BloodPack) then
call CustomVictoryBJ( GetLocalPlayer(), true, true )
else
call CustomDefeatBJ(GetLocalPlayer(), " You have met an unfortunate end, along with your clan.")
endif
elseif CrimsonHuntersCount > 0 and BloodPackCount == 0 and FangSquadCount == 0 and HellHordeCount == 0 and VileLegionCount == 0 and ChosenVampireCount == 0 and The11thCount == 0 then
call DisplayTextToForce(BloodPack, "You are Victorious! The Crimson Hunters reigns supreme.")
if IsPlayerInForce(GetLocalPlayer(), BloodPack) then
call CustomVictoryBJ( GetLocalPlayer(), true, true )
else
call CustomDefeatBJ(GetLocalPlayer(), " You have met an unfortunate end, along with your clan.")
endif
elseif VileLegionCount > 0 and BloodPackCount == 0 and FangSquadCount == 0 and HellHordeCount == 0 and CrimsonHuntersCount == 0 and ChosenVampireCount == 0 and The11thCount == 0 then
call DisplayTextToForce(BloodPack, "You are Victorious! The Vile Legion reigns supreme.")
if IsPlayerInForce(GetLocalPlayer(), BloodPack) then
call CustomVictoryBJ( GetLocalPlayer(), true, true )
else
call CustomDefeatBJ(GetLocalPlayer(), " You have met an unfortunate end, along with your clan.")
endif
elseif ChosenVampireCount > 0 and BloodPackCount == 0 and FangSquadCount == 0 and HellHordeCount == 0 and CrimsonHuntersCount == 0 and VileLegionCount == 0 and The11thCount == 0 then
call DisplayTextToForce(BloodPack, "You are Victorious! The Vile Legion reigns supreme.")
if IsPlayerInForce(GetLocalPlayer(), BloodPack) then
call CustomVictoryBJ( GetLocalPlayer(), true, true )
else
call CustomDefeatBJ(GetLocalPlayer(), " You have met an unfortunate end, along with your clan.")
endif
endif
endfunction
public function init takes nothing returns nothing
if not bj_isSinglePlayer and Mode != "Haven Control" then
debug call BJDebugMsg("it goes!")
call TimerStart(CreateTimer(), 8, true, function CheckForces)
endif
endfunction
endscope