Hi there, I'm tryna fix the star wars mod, currently this script, "ReflectSaber.lua" is being loaded by all guns from a variety of actors, instead of only being loaded by the HDfirearm it is a ScriptFile for.
Help me Data Realms Kinobis, you're my only hope. I'm currently digging through tutorials hoping to piece together the right "IF lightsaber then do this script, otherwise just don't." T_T
Code:
function Create(self)
local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then self.parent = ToActor(actor); end
if MovableMan:IsActor(self.parent) and self.RootID == self.parent.ID then
if self.Magazine ~= nil then
if self.HFlipped then self.negatore = 1 else self.negatore = -1 end
if not self.ReflectTimer:IsPastSimMS(310 - (20 * self.parent.Sharpness)) then
local blockang = self.BlockAngle
if not self.ReflectTimer:IsPastSimMS(35) then local rand = math.random(0,4) if rand == 1 then self.Magazine.Frame = 9; elseif rand == 2 then self.Magazine.Frame = 4; elseif rand == 3 then self.Magazine.Frame = 11; elseif rand == 4 then self.Magazine.Frame = 12; else self.Magazine.Frame = 4; end self.BlockAngle = blockang * 1.01; elseif not self.ReflectTimer:IsPastSimMS(55) then self.Magazine.Frame = 5 self.BlockAngle = blockang * 0.999; elseif not self.ReflectTimer:IsPastSimMS(95) then self.Magazine.Frame = 5 self.BlockAngle = blockang * 0.995; elseif not self.ReflectTimer:IsPastSimMS(120) then self.Magazine.Frame = 6 self.BlockAngle = blockang * 0.99; elseif not self.ReflectTimer:IsPastSimMS(155) then self.Magazine.Frame = 7 self.BlockAngle = blockang * 0.98; elseif not self.ReflectTimer:IsPastSimMS(210) then self.Magazine.Frame = 8 self.BlockAngle = blockang * 0.97; elseif not self.ReflectTimer:IsPastSimMS(260) then self.Magazine.Frame = 9 self.BlockAngle = blockang * 0.95; end
self.RotAngle = self.BlockAngle else self.Magazine.Frame = math.random(0,3); local blockang = self.BlockAngle if blockang ~= 0 then if blockang > math.pi then blockang = blockang - math.pi elseif blockang < -math.pi then blockang = blockang + math.pi end
if math.abs(self.BlockAngle) < (math.pi * 0.5) then self.BlockAngle = blockang * 0.8 else self.BlockAngle = blockang * 1.1
if math.abs(self.BlockAngle) >= math.pi then self.BlockAngle = 0; end end
if self.BlockAngle < -0.08 and self.BlockAngle > 0.08 then local rand = math.random(0,4) if rand < 2 then self.Magazine.Frame = 14 else self.Magazine.Frame = 15 end else self.Magazine.Frame = 16 end
if self.BlockAngle > -0.03 and self.BlockAngle < 0.03 then self.BlockAngle = 0; end self.RotAngle = self.RotAngle + blockang; end end
if self:IsActivated() then
local angmod = 0
if not self.SpinTimer:IsPastSimMS(2000) then if self.ReflectTimer:IsPastSimMS(470 - (20 * self.parent.Sharpness)) then angmod = math.sin(self.ReflectTimer.ElapsedSimTimeMS / 200) / 1.9; --self.Magazine.Frame = 8
if angmod == 0 then local soundfx = CreateAEmitter("Lightsaber Blade Sound"); soundfx.Pos = self.Pos; MovableMan:AddParticle(soundfx); end end else if self.ReflectTimer:IsPastSimMS(150) and self.BlockAngle == 0 then
local posneg = 1; angmod = self.anglemodifier
if angmod == 0 then local soundfx = CreateAEmitter("Lightsaber Swing"); soundfx.Pos = self.Pos; MovableMan:AddParticle(soundfx); end
if posneg == 1 then if angmod <= -7.2 then self.anglemodifier = 0; angmod = 0; self.SpinTimer:Reset(); end else if angmod >= 7.2 then self.anglemodifier = 0; angmod = 0; self.SpinTimer:Reset(); end end
self.anglemodifier = angmod + 0.27 * posneg local rand = math.random(0,4) if rand < 2 then self.Magazine.Frame = 14 else self.Magazine.Frame = 15 end if angmod >= (math.pi * 2) then self.anglemodifier = 0; angmod = 0; self.SpinTimer:Reset(); end end end
--SHIELD for particle in MovableMan.Particles do local pardist = SceneMan:ShortestDistance(self.Pos,particle.Pos,true);
if pardist.Magnitude < 25 then if particle.Team ~= self.Team then if particle.HitsMOs == false then
if pardist.Magnitude < 25 and particle.PresetName == "Lightsaber Killing B" and particle.Team ~= self.Team then if self.ammoCounter > 1 then -- particle.ToDelete = true;
local angle = SceneMan:ShortestDistance(self.Pos,particle.Pos, true).AbsRadAngle self.ReflectTimer:Reset(); self.randblock = math.random(-5,5);
--GRAZE BLOCK if pardist.Magnitude < 25 and particle.PresetName == "Lightsaber Killing C" and particle.Team ~= self.Team then if self.ammoCounter > 1 then
local angle = SceneMan:ShortestDistance(self.Pos,particle.Pos, true).AbsRadAngle self.ReflectTimer:Reset(); self.BlockAngle = angle;
self.ammoCounter = self.ammoCounter - 0.25; end end --END GRAZE BLOCK
if pardist.Magnitude < 20 and particle.PresetName == "Lightning Particle Null" and particle.Team ~= self.Team then particle.ToDelete = true;
if self.ammoCounter > 1 then self.ammoCounter = self.ammoCounter - 0.2; end end
elseif particle.HitsMOs == true then
if particle.ClassName == "MOPixel" and pardist.Magnitude < 25 and particle.Vel.Magnitude > 30 and particle.PresetName ~= "Lightsaber Killing B" and particle.Team ~= self.Team then if self.ammoCounter > 1 then local angle = SceneMan:ShortestDistance(self.Pos,particle.Pos, true).AbsRadAngle
local strikePoint = Vector(0,-1); self.parent:AddAbsForce((particle.Vel) * 0.5, strikePoint);
self.ammoCounter = self.ammoCounter - 1; end
elseif particle.ClassName ~= "MOPixel" and pardist.Magnitude < 25 and particle.Vel.Magnitude > 30 and particle.PresetName ~= "Lightsaber Killing B" and particle.Mass < 50 and particle.Team ~= self.Team then
particle.ToDelete = true;
local angle = SceneMan:ShortestDistance(self.Pos,particle.Pos, true).AbsRadAngle self.ReflectTimer:Reset(); self.randblock = math.random(-5,5);
self.BlockAngle = angle - self.randblock * 0.4;
local soundfx = CreateAEmitter("Lightsaber Deflect"); soundfx.Pos = particle.Pos; MovableMan:AddParticle(soundfx);
local strikePoint = Vector(0,-1); self.parent:AddAbsForce((particle.Vel) * 0.5, strikePoint); self.ReflectTimer:Reset();
if self.ammoCounter > 1 then self.ammoCounter = self.ammoCounter - 1; end end end end end end
--END SHIELD
--SWING
if self.ReflectTimer:IsPastSimMS(370 - (20 * self.parent.Sharpness)) then local rayL = 0; local vect = Vector(18,0);
local moid = SceneMan:CastMORay(self.Pos,vect,self.parent.ID,self.Team,0,false,0); if moid ~= 255 and moid ~= 0 then
local hitMO = MovableMan:GetMOFromID(moid); local root = MovableMan:GetMOFromID(hitMO.RootID);
if hitMO and not(MovableMan:IsActor(root) and ToActor(root).Health < 0) then if self.ammoCounter > 1 then self.ammoCounter = self.ammoCounter - 1;
end
local i = 0; while i < 2 do local burn2 = CreateMOPixel("Lightsaber Killing B", "empire_2018.rte"); burn2.Vel = vect; burn2.Pos = SceneMan:GetLastRayHitPos(); burn2.Team = self.Team; burn2.IgnoresTeamHits = true; MovableMan:AddParticle(burn2); i = i+1; end
if MovableMan:IsActor(root) then self.parent:SetWhichMOToNotHit(root,349) root:SetWhichMOToNotHit(self.parent,349) end end
local part = CreateAEmitter("Lightsaber Ground Impact"); part.Pos = SceneMan:GetLastRayHitPos(); MovableMan:AddParticle(part);
if hitMO and MovableMan:IsActor(root) and ToActor(root).Health > 0 then
local angle = SceneMan:ShortestDistance(self.Pos,root.Pos, true).AbsRadAngle
local burn = CreateMOPixel("Lightsaber Killing C", "empire_2018.rte"); burn.Vel = vect; burn.Pos = SceneMan:GetLastRayHitPos(); burn.Team = self.Team; burn.IgnoresTeamHits = true; --burn:SetWhichMOToNotHit(self.parent,-1); MovableMan:AddParticle(burn); end end --ENDBLOCKHIT end
--END SWING
else
local sharpness = self.parent.Sharpness; if self.rechargeTimer:IsPastSimMS(65 - sharpness * 5) and self.ammoCounter < sharpness * 35 then self.rechargeTimer:Reset(); self.ammoCounter = self.ammoCounter + 1; self.anglemodifier = 0; self.hitnum = 0; end end
self.Magazine.RoundCount = self.ammoCounter;
end
else local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then self.parent = ToActor(actor); end
self.Magazine.Frame = 13
end end
If it helps, this is the lightsaber's device.ini:
Code:
AddEffect = MOPixel PresetName = Lightsaber Beam White Mass = 0.01 GlobalAccScalar = 0 RestThreshold = -500 LifeTime = 5 //10 //5 Sharpness = 0 HitsMOs = 0 GetsHitByMOs = 0 Color = Color R = 255 G = 0 //255 B = 255 Atom = Atom Material = Material CopyOf = Air // TrailColor = Color // R = 255 // G = 0 // B = 255 // TrailLength = 0 //15
AddEffect = MOPixel PresetName = Lightsaber Killing A Mass = 0.01 //0.5 RestThreshold = 100 LifeTime = 20 //18 // PinStrength = 1000 Sharpness = 100 HitsMOs = 0 //1 GlobalAccScalar = 0 GetsHitByMOs = 0 Color = Color R = 255 G = 255 //0 B = 255 Atom = Atom Material = Material CopyOf = Bullet Metal TrailColor = Color R = 255 G = 255 //0 B = 255 TrailLength = 0
AddEffect = MOPixel PresetName = Lightsaber Killing B Mass = 0.05 RestThreshold = 500 //100 LifeTime = 25 //10 //20 ScriptPath = empire_2018.rte/Scripts/LightsaberKilling.lua Sharpness = 1000 HitsMOs = 0 GlobalAccScalar = 0 GetsHitByMOs = 0 Color = Color R = 255 G = 0 B = 255 Atom = Atom Material = Material CopyOf = Bullet Metal TrailColor = Color R = 255 G = 0 B = 255 TrailLength = 0 ScreenEffect = ContentFile FilePath = empire_2018.rte/Devices/Lightsaber/FireGlow1.bmp EffectStartTime = 0 EffectStopTime = 20 EffectStartStrength = 1.0 EffectStopStrength = 0 EffectAlwaysShows = 1
AddEffect = MOPixel PresetName = Lightsaber Killing C Mass = 0.05 RestThreshold = 500 //100 LifeTime = 25 //10 //20 ScriptPath = empire_2018.rte/Scripts/LightsaberKilling2.lua Sharpness = 5 HitsMOs = 0 GlobalAccScalar = 0 GetsHitByMOs = 0 Color = Color R = 255 G = 0 B = 255 Atom = Atom Material = Material CopyOf = Bullet Metal TrailColor = Color R = 255 G = 0 B = 255 TrailLength = 0
AddEffect = MOPixel PresetName = Lightsaber Lock Mass = 0.05 RestThreshold = 500 //100 LifeTime = 50 // ScriptPath = empire_2018.rte/Scripts/LightsaberKilling.lua Sharpness = 1000 HitsMOs = 0 GlobalAccScalar = 0 GetsHitByMOs = 0 Color = Color R = 255 G = 0 B = 255 Atom = Atom Material = Material CopyOf = Bullet Metal TrailColor = Color R = 255 G = 0 B = 255 TrailLength = 0 ScreenEffect = ContentFile FilePath = empire_2018.rte/Devices/Lightsaber/FireGlow1.bmp EffectStartTime = 0 EffectStopTime = 1000 EffectStartStrength = 1.0 EffectStopStrength = 1.0 EffectAlwaysShows = 1
AddEffect = MOPixel PresetName = Lightsaber Contact Flash Mass = 0.01 //0.1 LifeTime = 55 //20 Sharpness = 0.3 HitsMOs = 0 //1 GetsHitByMOs = 0 Color = Color R = 255 G = 255 B = 187 Atom = Atom Material = Material CopyOf = Air TrailColor = Color R = 255 G = 255 B = 159 TrailLength = 5 ScreenEffect = ContentFile FilePath = empire_2018.rte/Devices/Lightsaber/Impact.bmp EffectStartTime = 0 EffectStopTime = 55 EffectStartStrength = 1.0 EffectStopStrength = 0 EffectAlwaysShows = 1
AddEffect = MOPixel PresetName = Lightsaber Contact Flash Big Mass = 0.01 //0.1 LifeTime = 190 Sharpness = 0.3 HitsMOs = 0 //1 GetsHitByMOs = 0 Color = Color R = 255 G = 255 B = 187 Atom = Atom Material = Material CopyOf = Air TrailColor = Color R = 255 G = 255 B = 159 TrailLength = 5 ScreenEffect = ContentFile FilePath = empire_2018.rte/Devices/Lightsaber/LightFlash2.bmp EffectStartTime = 0 EffectStopTime = 190 //100 EffectStartStrength = 1.0 EffectStopStrength = 0 EffectAlwaysShows = 1
I'm not sure what the issue is exactly - a brief look doesn't suggest this script acts on every weapon with its code. The script should only act on the weapon you've attached it to with ini. In terms of checking if this do that, you can just do something like - if device.PresetName:find("Lightsaber") then {do stuff here} end.
Sun Mar 18, 2018 8:59 pm
polartechie
Joined: Tue May 06, 2014 9:11 pm Posts: 16
Re: Lua being applied to all guns?
Bad Boy wrote:
I'm not sure what the issue is exactly - a brief look doesn't suggest this script acts on every weapon with its code. The script should only act on the weapon you've attached it to with ini. In terms of checking if this do that, you can just do something like - if device.PresetName:find("Lightsaber") then {do stuff here} end.
Thank you. I did "disable" the lua with an if statement (I tried --if actor:HasObject("Lightsaber") and that did disable the bug for all other guns, so it is the culprit, but why it's being applied everywhere is still a mystery.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum