Blocking radar dot fire example

Blocking radar dot fire example

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Blocking radar dot fire example

Post by Google_Frog »

Gadget: https://github.com/ZeroK-RTS/Zero-K/blo ... _radar.lua
Example LUS: https://github.com/ZeroK-RTS/Zero-K/blo ... rmmerl.lua

This is a gadget that shows how I block firing at radar dots. It is a bit more complicated than that partially because I implemented the mechanic in some optional unit AI. I have some units with precise, long ranged, low AoE weapons so it is often wasteful for them to shoot at wobbly radar dots. The method in this gadget could probably be used for any type of conditional targeting.

I said that this gadget is messy but it is the method which is messy rather than the code. Units seem to acquire targets in many ways. Also I do not know which engine it was written for but it works with 97.0+ and I doubt I have looked at it in two years.

Units can fire while moving so must be able to acquire targets without any command handling. Units can also give themselves attack commands when idle and this command seems to interfere with SetUnitTarget. So both SetUnitTarget and command queue editing have to be used. I distinguish between commands given by units (internal commands) and those issued by players by not removing the player command. This means that a unit told to attack an illegal target will wait until the target is legal.

This gadget uses AllowWeaponTarget. The important thing about this callin is that it is called every 16 frames. This is fine by me because it seems to be called for every unit within the range of every other unit, the performance implications are scary.

The limitation of AllowWeaponTarget leads to the tedious part of implementing this for all units in a game. Units which use this gadget need to call a notification function in script.AimWeapon and a block check in script.BlockShot. The gadget is only reliable due to BlockShot and this can add targeting delay.
Post Reply

Return to “Lua Scripts”