print("TRL_TikiTakGeneral is loaded");
-- The custom mission we're interested in
local iMissionHypnotize = GameInfoTypes.MISSION_TRL_HYPNOTIZE --both these are correct in regards to spelling
local iTiki = GameInfoTypes.UNIT_TRL_TIKI
-- Return value constants needed by CustomMissionStart, do not change these, just use them
local CUSTOM_MISSION_NO_ACTION = 0
local CUSTOM_MISSION_ACTION = 1
local CUSTOM_MISSION_DONE = 2
local CUSTOM_MISSION_ACTION_AND_DONE = 3
function OnCustomMissionPossible(iPlayer, iUnit, iMission, iData1, iData2, _, _, iPlotX, iPlotY, bTestVisible)
[COLOR="darkred"]print("OnCustomMissionPossible fires");[/COLOR] --this never shows in the logs
if (iMission == iMissionHypnotize) then
local pPlayer = Players[iPlayer]
local pUnit = pPlayer:GetUnitByID(iUnit)
-- Can this particular unit type for this player perform this mission? In our case only Clan Magicians can
if (pUnit:GetUnitType() == iTiki) then
print("Tiki mission possible; This unit is a Tiki");
-- So we know the unit could perform the mission, but does it meet all the circumstantial conditions, ie, is the unit within our territory? (this is still some 'junk-text' left from the Tutorial; ignore)
if (AnyAdjacentUnitsAtWar(iPlayer,iUnit)) then --AnyAdjacentUnitsAtWar is defined below and not part of my current question
print("Tiki mission possible; Adjacent units that are at war");
-- Circumstantial conditions NOT met (not adjacent to any units), return the value of bTestVisible
return bTestVisible
end
-- All conditions met, so we can perform the action
return true
end
end
-- The unit can't perform the mission - return false
return false
end
GameEvents.CustomMissionPossible.Add(OnCustomMissionPossible)
--CustomMissionStart, etc. are all below; I didn't paste them here since I never even got to testing them...
[...]