View unanswered posts | View active topics It is currently Tue Aug 21, 2018 8:42 am



Reply to topic  [ 4 posts ] 
 force shield 
Author Message

Joined: Wed Sep 28, 2011 2:35 am
Posts: 8
Reply with quote
Post force shield
hi, some time ago someone post the force shield like the protoos units, there is a little problem with that the shield by some weapons can be penetrated before it's break, the missiles can penetrate it, slowly but they can and some gun shots like the shot of the sjg-4 of the werhmacht mod, the missiles suppose to explode in the surface of the shield, no transpassing it, so i'm wandering if it's a propertie that change this or some command line in the lua script or in the ini file

this is the lua script: i'm already modificate it, only the resistence of the shield.


function Create(self)
self.shieldmult = 0.8 --set the multiplier to slow particles with
self.counter = 0; --set shield damage to 0
self.countertime = Timer() --set the regen timer
local curdist = 80; --find the closest actor, set it to be self.parent
for actor in MovableMan.Actors do
local avgx = actor.Pos.X - self.Pos.X;
local avgy = actor.Pos.Y - self.Pos.Y;
local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
if dist < curdist then
curdist = dist;
self.parent = actor;
end
end

self.yellow = CreateAEmitter("forceshieldwall2b") --create the yellow glow emitter
self.red = CreateAEmitter("forceshieldwall3") --and the red
self.yellow.Pos = self.Pos --and place them on self
self.red.Pos = self.Pos
MovableMan:AddParticle(self.yellow) --and add them on scene
MovableMan:AddParticle(self.red)

if self.parent ~= nil then --if parent was found calculate offset vector to it
self.offset = Vector(self.parent.Pos.X - self.Pos.X , self.parent.Pos.Y - self.Pos.Y)
end

self.disptime = Timer() --set the print timer

end


function Update(self)
if MovableMan:IsActor(self.parent) then --make sure parent is accessible to avoid crashing
self.Pos = self.parent.EyePos --set the center of the shield and coloured emitters to the parent's head
self.yellow.Pos = self.parent.EyePos
self.red.Pos = self.parent.EyePos
self.impulse = Vector(0,0) --reset impulse
for particle in MovableMan.Particles do --cycle through particles
if particle.HitsMOs == true then --if the particle is dangerous
dist = SceneMan:ShortestDistance(self.Pos , particle.Pos , true) --get a vector pointing to the particle
if dist.Magnitude < 60 and (not(self.PresetName == particle.PresetName)) then --if the particle is close
if math.abs(particle.Vel.AbsRadAngle - dist.AbsRadAngle) > math.pi / 4 then --if the particle is headed towards parent
self.impulse = Vector(self.impulse.X + particle.Vel.X * self.shieldmult * particle.Mass , self.impulse.Y + particle.Vel.Y * self.shieldmult * particle.Mass) --add the force caused by the particle to impulse
--self.impulse:CapMagnitude(1200)
particle.Vel = Vector(particle.Vel.X * self.shieldmult , particle.Vel.Y * self.shieldmult) --slow down the particle
self.counter = self.counter + math.abs(particle.Mass) * particle.Vel.Magnitude / self.shieldmult --decrease the strength of the shield
self.countertime:Reset() --reset the shield recharge time
self.glow = CreateMOSParticle("Shield glow") --create a glow on the particle
self.glow.Pos = particle.Pos
MovableMan:AddParticle(self.glow)
end
end
end
end
for particle in MovableMan.Items do --do the same thing to items
dist = SceneMan:ShortestDistance(self.Pos , particle.Pos , true)
if dist.Magnitude < 60 and (not(self.PresetName == particle.PresetName)) and particle.Vel.Magnitude > 5 then
if math.abs(particle.Vel.AbsRadAngle - dist.AbsRadAngle) > math.pi / 4 then
self.impulse = Vector(self.impulse.X + particle.Vel.X * self.shieldmult * particle.Mass , self.impulse.Y + particle.Vel.Y * self.shieldmult * particle.Mass)
--self.impulse:CapMagnitude(2200)
particle.Vel = Vector(particle.Vel.X * self.shieldmult , particle.Vel.Y * self.shieldmult)
self.counter = self.counter + math.abs(particle.Mass) * particle.Vel.Magnitude / self.shieldmult
self.countertime:Reset()
self.glow = CreateMOSParticle("Shield glow") --create a glow on the particle
self.glow.Pos = particle.Pos
MovableMan:AddParticle(self.glow)
end
end
end
self.impulse:SetMagnitude(self.impulse.Magnitude * 2)
self.parent:AddAbsImpulseForce(self.impulse , self.parent.Pos) --give parent a jolt
else --if parent is dead, gib the shield and the colour emitters
self:GibThis()
self.yellow:GibThis()
self.red:GibThis()
end

if self.counter < 20500 then --if the shield is strong disable non-blue emitters, enable blue, set shield velocity multiplier to be small
self:EnableEmission(true)
self.yellow:EnableEmission(false)
self.red:EnableEmission(false)
self.shieldmult = 50
end
if self.counter > 20500 and self.counter < 30000 then --if the shield has taken some damage, enable yellow emitter, disable others, set shield velocity multiplier to be medium
self:EnableEmission(false)
self.yellow:EnableEmission(true)
self.red:EnableEmission(false)
self.shieldmult = 0.5
end
if self.counter > 30000 then --if the shield is weak, enable red, disable others, set shield velocity multiplier to be large
self:EnableEmission(false)
self.yellow:EnableEmission(false)
self.red:EnableEmission(true)
self.shieldmult = 0.7
end
if self.counter > 50000 then --if the shield is too damaged, gib it and the emitters
self:GibThis()
self.yellow:GibThis()
self.red:GibThis()
end

if self.countertime:IsPastSimMS(3000) and self.counter > 0 then --if the shield hasn't taken hits in 3 seconds start regenerating it
self.counter = self.counter - 600 * TimerMan.DeltaTimeSecs
end

if self.disptime:IsPastSimMS(500) then --print shield strength every half a second
print(math.floor(self.counter))
self.disptime:Reset()
end

end

function Destroy(self)
end


plz help :) thnks


Sat Mar 17, 2012 3:25 am
Profile
User avatar

Joined: Mon Apr 13, 2009 12:27 pm
Posts: 813
Location: Yogyakarta, Indonesia. A slice o' paradise.
Reply with quote
Post Re: force shield
Whoa nelly, that code bit could be spoilered and put in the code tag.

So that people could
1) easily read it
2) easily copy it
Because if you just pasted it on like that, people would have trouble copying it into a .lua file, because forum formatting does things to text like that.

If you're feeling more adventurous, try attaching the .lua file, or a .rar of the .rte here.

Good luck!


Sat Mar 17, 2012 4:01 pm
Profile YIM WWW

Joined: Mon Dec 07, 2009 12:56 am
Posts: 36
Reply with quote
Post Re: force shield
Sorry I cannot help you with this scripting, but I did want to mention that your shield if it works as advertised interests me greatly. Some of Mehman's units that have a shield stop bullets, but reflect things like launched grenades and rockets. That type while extemely entertaining, can be a bit OP. A version that takes a rocket in the chin and can also stop all the particles spewed from the blast, but lose alot of it's energy sounds like something I would add to this robot soldier I'm making.


Mon Apr 09, 2012 1:24 am
Profile

Joined: Mon Aug 22, 2011 3:12 am
Posts: 102
Reply with quote
Post Re: force shield
Where could I find the original script?


Sat Apr 14, 2012 7:47 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.017s | 13 Queries | GZIP : Off ]