New Lua function: HasClearFiringLine

New Lua function: HasClearFiringLine

Requests for features in the spring code.

Moderator: Moderators

Post Reply
jseah
Posts: 42
Joined: 10 Jun 2008, 03:28

New Lua function: HasClearFiringLine

Post by jseah »

http://springrts.git.sourceforge.net/gi ... b6;hb=HEAD

Could I request that HaveFreeLineOfFire or TryTarget become callable as a Lua function?

More precisely, I would like a function that returns true/false depending on whether a specific unit's specific weapon can fire at a target point.

EDIT:
Ability to accept hypothetical units would be VERY nice. (unitID replaced with unitDefID and x/y/z unit position)

This would greatly help unit AI determine good targets as well as tower placement for full AIs.
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: New Lua function: HasClearFiringLine

Post by SpliFF »

+1 , I see this as a very useful feature, especially the virtual firing test. It should probably consist of a range of functions or overloaded variations:

The base function could be:

Code: Select all

trueOrFalse = GetWeaponCanHitPos(weaponDefId, locX, locY, locZ, targetX, targetY, targetZ, [checkMobile], [checkBuildings], [checkFeatures], [checkAllies])
checkMobile, checkBuildings, checkFeatures and checkAllies would be optional flags to determine what obstacles are consider blocking for the purpose of the calculation.

From that base function a range of convenience functions could be defined either in the engine or in the mod, such as

Code: Select all

-- Return weapon id of first weapon that can hit, or null if can't.
GetUnitCanHitPos(unitID, targetX, targetY, targetZ)
GetDefCanHitPos(defID, locX, locY, locZ, targetX, targetY, targetZ)
GetUnitCanHitDef(unitID, defID, targetX, targetY, targetZ)
GetDefCanHitDef(defID, defID, locX, locY, locZ, targetX, targetY, targetZ)
GetUnitCanHitUnit(unitID, unitID)
GetDefCanHitUnit(defID, unitID, locX, locY, locZ)
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: New Lua function: HasClearFiringLine

Post by Anarchid »

This is relevant to my interests. That thing i should be working on, one module in it always gets stuck when units are ordered to shoot at ground that they can't shoot.
Post Reply

Return to “Feature Requests”