Did a short little script to allow my bot to look like any prop its standing next to.
Video (or it didn't happen): https://youtu.be/frnP8V9ZPW8
Script...
-----------------------------------------------------------------------------
-- File : /units/ual0204/ual0204_script.lua
--
-- Author(s): EbolaSoup, Resin Smoker, Optimus Prime, Vissroid
--
-- Summary : Aeon T2 Sniper Bot
--
-- Copyright © 2024 4DFAF, All rights reserved.
-----------------------------------------------------------------------------
-- Misc Lua called
local AWalkingLandUnit = import('/lua/aeonunits.lua').AWalkingLandUnit
local EffectUtils = import('/lua/EffectUtilities.lua')
local EffectTemplate = import('/lua/effecttemplates.lua')
local Custom_4D_EffectTemplate = import('/mods/4DFAF/lua/4D_EffectTemplates.lua')
local utilities = import('/lua/utilities.lua')
local myDebug = false
-- Weapon Local lua called
local SniperWeapon = import('/lua/aeonweapons.lua').ADFDisruptorCannonWeapon
-- Bones for weapon recoil effects
local weaponBones = { 'sniper_rifle', 'sniper_barrel' }
ual0204 = Class(AWalkingLandUnit) {
Weapons = {
-- Shield Piercing Rifle
Sniper_Piercing_Rifle = Class(SniperWeapon) {
PlayFxMuzzleSequence = function(self, muzzle)
for k, v in weaponBones do
local steamEffects = EffectUtils.CreateBoneEffects( self.unit, v, self.unit:GetArmy(), EffectTemplate.WeaponSteam01 )
end
local groundEffects = EffectUtils.CreateBoneEffects( self.unit, 'ual0204', self.unit:GetArmy(), Custom_4D_EffectTemplate.ConcussionRing )
if self.unit.CamoEntity then
self.unit.CamoEntity:Destroy()
self.unit.CamoEntity = nil
self.unit:DisableIntel('Cloak')
self.unit:SetVizToFocusPlayer('Always')
self.unit:SetVizToAllies('Always')
end
SniperWeapon.PlayFxMuzzleSequence(self)
end,
},
},
OnCreate = function(self,builder,layer)
AWalkingLandUnit.OnCreate(self)
self:DisableIntel('Cloak')
self.CamoEntity = nil
end,
OnMotionHorzEventChange = function(self, new, old)
if myDebug then WARN('OnMotionHorzEventChange') end
if self and not self:IsDead() then
if new == 'Stopped' then
if myDebug then WARN(' Stopped') end
local propTbl = self:GetPropsInRadius(2)
local propBp = propTbl[1].prop.Blueprint
if myDebug then WARN(' prop blueprint '..repr(propBp) ) end
local mesh = propBp.Display.MeshBlueprint or nil
local scale = propBp.Display.UniformScale
if myDebug then WARN(' Mesh / Scale: ', mesh, scale) end
if mesh then
self:EnableIntel('Cloak')
self:SetVizToFocusPlayer('Never')
self:SetVizToAllies('Never')
self.CreateCamoEntity(self, mesh, scale)
end
else
if myDebug then WARN(' moving') end
if self.CamoEntity then
self.CamoEntity:Destroy()
self.CamoEntity = nil
self:DisableIntel('Cloak')
self:SetVizToFocusPlayer('Always')
self:SetVizToAllies('Always')
end
end
end
AWalkingLandUnit.OnMotionHorzEventChange(self, new, old)
end,
CreateCamoEntity = function(self, mesh, scale)
if myDebug then WARN('CreateCloakEntity') end
ent = import('/lua/sim/Entity.lua').Entity({Owner = self,})
ent:AttachBoneTo( -1, self, 'ual0204' )
ent:SetMesh(mesh)
ent:SetDrawScale(scale or 1)
ent:SetVizToFocusPlayer('Always')
ent:SetVizToAllies('Always')
ent:SetVizToNeutrals('Intel')
ent:SetVizToEnemies('Intel')
self.CamoEntity = ent
self.Trash:Add(ent)
end,
GetPropsInRadius = function(self, radius)
if myDebug then WARN('GetPropsInRadius') end
radius = radius or 1
local pos = self:GetPosition()
local props = GetReclaimablesInRect(Rect(pos[1] - radius, pos[3] - radius, pos[1] + radius, pos[3] + radius))
if table.getn(props) then
local propsByDist = {}
for a, b in props do
if not b:BeenDestroyed() then
if not IsUnit(b) and not b.IsWreckage then
table.insert(propsByDist, {dist = utilities.XZDistanceTwoVectors(pos, b:GetPosition()), prop = b})
end
end
end
if myDebug then WARN(' num props after filter: ', table.getn(propsByDist)) end
table.sort(propsByDist, sort_by('dist'))
return propsByDist
else
if myDebug then WARN(' no props in radius') end
return false
end
end,
}
TypeClass = ual0204
Still a lot of work to do on this concept, but at least the hard part is done.
Resin