Chrisy15
Flower, Beautiful
- Joined
- Jul 9, 2015
- Messages
- 2,137
Hi
I've recently added a Wonder Unit (<MaxGlobalInstances>1</MaxGlobalInstances>) to my mod, and I was wanting a notification to pop up, like what you get for building a wonder. Having looked at Firaxis' code, I decided to have a go, but I've got no real idea what I'm doing. Can anyone help?
What I came up with:
Also, a notification for the unit dying would be nice, although there may be issues with that if the unit upgrades.
I've recently added a Wonder Unit (<MaxGlobalInstances>1</MaxGlobalInstances>) to my mod, and I was wanting a notification to pop up, like what you get for building a wonder. Having looked at Firaxis' code, I decided to have a go, but I've got no real idea what I'm doing. Can anyone help?
What I came up with:
Spoiler :
Code:
print("300 Notification is working!");
local is300Ready = false;
function Is300Ready(iPlayer)
local pPlayer = Players[iPlayer];
if PlayerCanTrain (pPlayer, GameInfoTypes["UNIT_300"]) == true then
is300Ready = true;
GameEvents.PlayerDoTurn.Remove(Is300Ready);
end
end
GameEvents.PlayerDoTurn.Add(Is300Ready);
function Is300Built(iPlayer)
local pPlayer = Players[iPlayer]
if (PlayerCanTrain(pPlayer, GameInfoTypes["UNIT_300"]) == false) and (is300Ready == true) then
local portraitIndex = GameInfo.Units["UNIT_300"].PortraitIndex;
IconHookup( portraitIndex, 80, GameInfo.Units["UNIT_300"].IconAtlas, instance.WonderConstructedAlphaAnim );
GameEvents.PlayerDoTurn(iPlayer).Remove(Is300Built);
end
if iExtraGameData ~= -1 then
CivIconHookup (iExtraGameData, 45, instance.CivIcon, instance.CivIconBH, instance.CivIconShadow, false, true );
instance.WonderSmallCivFrame:SetHide(false);
GameEvents.PlayerDoTurn.Remove(Is300Built);
end
end
GameEvents.PlayerDoTurn.Add(Is300Built);
Also, a notification for the unit dying would be nice, although there may be issues with that if the unit upgrades.