Tracers


#1

Hate the current system, wanna bash something together with either lua ProjectileCreated callin or ShotX in lus, and LUPS.

Info on colours:

bbs.hitechcreations.com/smf/inde … c=157610.0

forum.1cpublishing.eu/archive/in … 12320.html

books.google.co.uk/books?id=-Zq … ur&f=false

#ShouldaBeenAGithubIssue

edit:

[code]
tracerCache = {} – {weaponDefID = {params}} params contains colour, thickness, length

Initailize()
for weaponDefID, weaponDef in pairs(WeaponDefs) do
if weaponDef.customparams.tracer then
tracerCache[weaponDefID] = loadstring(weaponDef.customparams.tracer)
end
end
end

local roundNumber = {} – {unitID = {weaponNum = roundNum}}
ProjectileCreated(proID, proOwnerID, weaponDefID)
if tracerCache[weaponDefID] then
– problem is determining which weapon fired if unit has multiple copies of one weapon
– e.g. aircraft we want tracers to be per gun, not per weaponDef
local weaponNum = magic()
if not roundNumber[unitID] then roundNumber[unitID] = {} end
local roundNum = roundNumber[unitID][weaponNum] or 1
if roundNum == 5 then – customparam this later too
AddToSendToUnsyncedCache(proID, tracerCache[weaponDefID]) – creation calls are batched to reduce synced->unsynced communication
roundNumber[unitID][weaponNum] = 0
else
roundNumber[unitID][weaponNum] = roundNumber[unitID][weaponNum] + 1
end
end
[/code]


#2

I think doing it from the unit script’s Shot() callin is your best way for getting the weapon fired.
Batching may be slightly more difficult, but it’s probably possible.


#3

The problem is that Shot() doesn’t know the projectile ID… The LUS could set a rulesparam or some other synced message to communicate the most recently fired weapon… that will work if the order of execution doesn’t result in anything awful happening, which it might. Alternatively the gadget could use GetUnitWeaponInfo to look at reload frames and see which one had just fired (like ammo gadget) but it is possible for 2 weapons to fire in the same frame, basically the same problem as above.