Need some lua to actor (LaserHead)
I need lua for the actor, are follows:
Actor would have a laser sight, as Techion nanorifle, where you look, there is laser, it better to be from the head and not from body.
Experimental code:
Code:
dofile("Base.rte/Constants.lua")
require("Actors/AI/NativeHumanAI")
function Create(self)
self.AI = NativeHumanAI:Create(self);
self.laserTimer = Timer();
self.laserLength = 800;
self.laserSpaceCheck = 5; -- For optimization purposes. Smaller value means a more accurate but slower check.
self.laserDensity = math.ceil(self.laserLength/self.laserSpaceCheck);
end
function Update(self)
if self.laserTimer:IsPastSimMS(50) then
self.laserTimer:Reset();
if self:GetController():IsState(Controller.AIM_SHARP) and self:IsPlayerControlled() == true then
local roughLandPos = self.EyePos + Vector(self.laserLength,0):RadRotate(self):GetAimAngle(true);
for i = 0, self.laserDensity do
local checkPos = self.EyePos + Vector(self.laserSpaceCheck*i,0):GetAimAngle(true);
if SceneMan.SceneWrapsX == true then
if checkPos.X > SceneMan.SceneWidth then
checkPos = Vector(checkPos.X - SceneMan.SceneWidth,checkPos.Y);
elseif checkPos.X < 0 then
checkPos = Vector(SceneMan.SceneWidth + checkPos.X,checkPos.Y);
end
end
local terrCheck = SceneMan:GetTerrMatter(checkPos.X,checkPos.Y);
if terrCheck == 0 then
local moCheck = SceneMan:GetMOIDPixel(checkPos.X,checkPos.Y);
if moCheck ~= rte.NoMOID and MovableMan:GetMOFromID(moCheck).Team ~= self.Team then
roughLandPos = checkPos;
break;
end
else
roughLandPos = checkPos;
break;
end
end
local checkRoughLandPos = roughLandPos + Vector(self.laserSpaceCheck*-1,0):RadRotate(self):GetAimAngle(true);
for i = 0, self.laserSpaceCheck do
local checkPos = checkRoughLandPos + Vector(i,0):GetAimAngle(true);
if SceneMan.SceneWrapsX == true then
if checkPos.X > SceneMan.SceneWidth then
checkPos = Vector(checkPos.X - SceneMan.SceneWidth,checkPos.Y);
elseif checkPos.X < 0 then
checkPos = Vector(SceneMan.SceneWidth + checkPos.X,checkPos.Y);
end
end
local terrCheck = SceneMan:GetTerrMatter(checkPos.X,checkPos.Y);
if terrCheck == 0 then
local moCheck = SceneMan:GetMOIDPixel(checkPos.X,checkPos.Y);
if moCheck ~= 255 then
break;
end
else
break;
end
roughLandPos = checkPos;
end
local laserPar = CreateMOPixel("Nanorifle Laser Sight Glow");
laserPar.Pos = roughLandPos;
MovableMan:AddParticle(laserPar);
end
end
end
function UpdateAI(self)
self.AI:Update(self)
end
Does not work. In the console error:
ERROR: no overload of 'Vector: RadRotate' matched the arguments (Vector, AHuman)
candidates are:
Vector: RadRotate (custom [float])
Is nothing said for me.