ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();
if(pkScriptSystem) {
CvLuaArgsHandle args;
args->Push(eEvent);
args->Push(eAIPlayer);
args->Push(iArg1);
args->Push(iArg2);
bool bResult;
LuaSupport::CallHook(pkScriptSystem, "[B][COLOR="red"]UiDiploEvent[/COLOR][/B]", args.get(), bResult);
}
function OnUiDiploEvent(iDiploEvent, iPlayerWith, iButton, iPlayerAgainst)
-- Do something
end
GameEvents.[B][COLOR="Red"]UiDiploEvent[/COLOR][/B].Add(OnUiDiploEvent)
Drawmeus, I also am interested in creating onBuildBuilding() and onSellbuilding() game events; however, I am sorely lacking in C++ expertise. If you get a chance would you explain the code or possibly make a tutorial?
m_pCityBuildings->SetNumRealBuilding(eBuildingType, m_pCityBuildings->GetNumRealBuilding(eBuildingType) + 1);
// STRABO - Adding new GameEvent: StraboOnBuildingCreated
ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();
if(pkScriptSystem)
{
CvLuaArgsHandle args;
args->Push(this->getX());
args->Push(this->getY());
args->Push(eBuildingType);
args->Push(kPlayer.GetID());
args->Push(GetID());
bool bResult;
LuaSupport::CallHook(pkScriptSystem, "StraboOnBuildingCreated", args.get(), bResult);
}
function OnBuildingCreated(Xcoord, Ycoord, buildingID, ownerID, cityID)
print("OnBuildingCreated");
local pPlayer = Players[ ownerID ];
print("Player: " .. Locale.ConvertTextKey(pPlayer:GetCivilizationShortDescriptionKey()));
local pBuilding = GameInfo.Buildings[ buildingID ];
print("Building: " .. Locale.ConvertTextKey(GameInfo.Buildings[ buildingID ].Description));
local pCity = pPlayer:GetCityByID( cityID );
print("City: " .. pCity:GetName() );
end
GameEvents.StraboOnBuildingCreated.Add(OnBuildingCreated)
I'm not sure if there are any edge cases I missed - I don't know what will happen if you grant the building through lua, say.
I did not test the X,Y coordinates yet, so I don't know for sure that they're working.
So as fully tested as the ones added by Firaxis then. Job done. Push it out in the next patch
(In case it's not clear, this is slagging off the Firaxis dev team, not Drawmeus)
Now, i know this has been discussed several times before, but considering that dll mods will become more and more common (unless Firaxis breaks something again in a future patch), do you, "dll modders" think it would be a good idea, and something possible to release some sort of "community dll mod", using whoward's modular dll approach to include all those small, smart additions. Then modders could use this dll in their own mods.One word of warning for anyone using the code I just posted - I would most certainly NOT use a DLL mod if this is the only thing you're doing in it. It will immediately break compatibility with all other mods that modify the DLL ...