Data Realms Fan Forums
http://45.55.195.193/

Controlling penetration
http://45.55.195.193/viewtopic.php?f=73&t=16361
Page 1 of 1

Author:  MaximDude [ Wed Aug 26, 2009 6:06 pm ]
Post subject:  Controlling penetration

Honestly, I don't even know how to explain this in a few words, so controlling penetration seems closest to what i'm aking. >_________________>'

Anyway, what i'm planing on making is a stationary energy shield module that will allow units to fire through it, but not get fired at through it.

Like, you have this shield, and there is a unit at it's left side, and an enemy at it's right side.
The unit on the left can shoot through the shield at the enemy on the right, but the enemy can't.

I was thinking maybe have a proximity check that check from which side the particle is travelling (left/right, though i'm not quite sure how to do this) and the set the shield to GHBM 0/1.
Or maybe use 'SetWhichMONotToHit' if it works the other way around (Instead of setting what to hit and what not, set what to get hit by and what not)

Can it be done properly?

Author:  Roon3 [ Wed Aug 26, 2009 6:09 pm ]
Post subject:  Re: Controlling penetration

Velocity (Direction) checks and SetWhichMONotToHit should do the trick.

Author:  piipu [ Wed Aug 26, 2009 7:56 pm ]
Post subject:  Re: Controlling penetration

It shouldn't be too hard. See my MC2 entry for reference.

Author:  Duh102 [ Wed Aug 26, 2009 8:06 pm ]
Post subject:  Re: Controlling penetration

Also mine. I have something in there that does exactly what you're talking about, but I think I had some problems with particles coming and going from below.

Author:  MaximDude [ Thu Aug 27, 2009 12:02 am ]
Post subject:  Re: Controlling penetration

Duh102 wrote:
Also mine. I have something in there that does exactly what you're talking about, but I think I had some problems with particles coming and going from below.


That's not an issue, because there won't be any particles coming from below, and its not going to be a circle, but a box.

I just hope i'll manage to convert it without ♥♥♥♥ up everything, cuase it looks somewhat complicated and over my current level of lua mastery. >___________>'

I also looked at Piipu's code, but that's waaaaaaaaaay, waaaaaaaaaaaaaaay, waaaaaaaaaaaaaaaaaaaaaaay too complicated.

Author:  Duh102 [ Thu Aug 27, 2009 12:15 am ]
Post subject:  Re: Controlling penetration

My code is mostly just the distance check, plus this bit here.
Code:
         local normal = math.atan2(-((self.Pos.Y - 12) - particle.Pos.Y), (self.Pos.X - particle.Pos.X));
         local particleHeading = math.atan2(-(particle.Vel.Y), (particle.Vel.X));
         if math.abs((normal + (3/2 * math.pi)) - (particleHeading + (3/2 * math.pi))) <= (math.pi/2) then
            ...
         end

This is the part that checks the direction of the particle in question. You put what you want to do where the ... is. This is for a circular check though. Not sure how you would do it for a box.

Author:  Grif [ Thu Aug 27, 2009 12:18 am ]
Post subject:  Re: Controlling penetration

for particle in MovableMan.Particles do
if particle.ClassName == "MOPixel" then
if self.whateverboxnameyouhavedefined:WithinBox(particle.Pos) == true then
if particle.Vel.X < 0 then
particle:SetWhichMOToNotHit(self,-1);
end
end
end
end

Will only work on mopixels, and you can only shoot through from the left. Also inefficient and requires a pre-defined box.

Author:  MaximDude [ Thu Aug 27, 2009 12:33 am ]
Post subject:  Re: Controlling penetration

Grif wrote:
for particle in MovableMan.Particles do
if particle.ClassName == "MOPixel" then
if self.whateverboxnameyouhavedefined:WithinBox(particle.Pos) == true then
if particle.Vel.X < 0 then
particle:SetWhichMOToNotHit(self,-1);
end
end
end
end

Will only work on mopixels, and you can only shoot through from the left. Also inefficient and requires a pre-defined box.


A pre-defined box isn't an issue, though shooting only from the left is... Oh well, I'll just make 2 versions.

And it will probably work if I did 'if particle.ClassName == "MOPixel" or particle.CalssName == "MOSRotating" or particle.ClassName == "MOSParticle" then'

I will find out in 10-12 hours, once I wake up and start working on it.

Author:  Grif [ Thu Aug 27, 2009 12:59 am ]
Post subject:  Re: Controlling penetration

Yes and yes.

If it's a bunkermodule (the impression I got) then yeah, two versions is your best bet.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/