Custom bombardment/hex selection

Agentis

Chieftain
Joined
Aug 1, 2007
Messages
5
So I'm trying to add non-combat, non-improvement spell-like abilities to units. Copying some code from Bombardment.lua, I can make the bombardment interface appear in order to prompt the player to select a target, but I can't figure out how to hook up an event for when the user then clicks on the desired target.

Using an event such as
Code:
Events.SerialEventHexSelected.Add(EndSpell);
never seems to fire the method; anyone tried this before or have any ideas?
 
Noticed an interesting peculiarity; if you enable debug mode in the Civ config file and then open the debug window in-game, the event does trigger (you have to double click to trigger as well, but thats managable sort of). So whats the magic in there I wonder..
 
The reason for peculiarity might be that DebugMode.lua is the only game file which uses SerialEventHexSelected event, and does some actions when it's triggered. Maybe devs created event for debug purposes only...

In general, if you look into WorldView.lua, there is an "input handler", which looks like

Code:
function InputHandler( uiMsg, wParam, lParam )
.. do smthing .. 
end
ContextPtr:SetInputHandler( InputHandler );

the arguments which input handler receives contain information about what mouse/keyboard keys are pressed. You can then check if player pressed the mouse button, check whether the proper interface is selected (your magic action), and whether the mouse is over a proper plot. This is how the game does it anyway. It would be nice to have a single event to do all of that, but I'm not sure if such event exists.
 
Back
Top Bottom