[BNW] Need help: Event for Unit Combat

Kewlipo

Chieftain
Joined
Jun 27, 2015
Messages
99
In most basic terms, I am trying to bump up a counter every time combat occurs. I can't find any events that fire for this, Events.RunCombatSim and Events.EndCombatSim seem to flat out not work.

Naturally, I was trying to figure out how to hook onto combat experience changing but I could not find anything connected to that either.

I've resolved to try to add a new event to GameEvents (I am quite a novice at C++) but I can't seem to find GameEvents! I have found where Lua methods are defined but GameEvents simply eludes me! :crazyeye:

If anyone could point me in the right direction (or perhaps propose a different way to go about this I might have missed...) it would be greatly appreciated.
 
Nevermind - I did it after scouring the DLL for some examples.

Added this to the ResolveCombat method:

Code:
        ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();
        if (pkScriptSystem && pAttacker && pDefender)
        {   
            CvLuaArgsHandle args;
            
            args->Push(pAttacker->getOwner());
            args->Push(pDefender->getOwner());

            bool bResult;
            LuaSupport::CallHook(pkScriptSystem, "UnitCombatOccurred", args.get(), bResult);
        }
 
Back
Top Bottom