Author |
Message |
MaximDude
Joined: Wed Nov 22, 2006 3:19 pm Posts: 2073
|
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?
|
Wed Aug 26, 2009 6:06 pm |
|
|
Roon3
Joined: Sun May 11, 2008 12:50 pm Posts: 899
|
Re: Controlling penetration
Velocity (Direction) checks and SetWhichMONotToHit should do the trick.
|
Wed Aug 26, 2009 6:09 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Controlling penetration
It shouldn't be too hard. See my MC2 entry for reference.
|
Wed Aug 26, 2009 7:56 pm |
|
|
Duh102
happy carebear mom
Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
|
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.
|
Wed Aug 26, 2009 8:06 pm |
|
|
MaximDude
Joined: Wed Nov 22, 2006 3:19 pm Posts: 2073
|
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.
|
Thu Aug 27, 2009 12:02 am |
|
|
Duh102
happy carebear mom
Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
|
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.
|
Thu Aug 27, 2009 12:15 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
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.
|
Thu Aug 27, 2009 12:18 am |
|
|
MaximDude
Joined: Wed Nov 22, 2006 3:19 pm Posts: 2073
|
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.
|
Thu Aug 27, 2009 12:33 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Controlling penetration
Yes and yes.
If it's a bunkermodule (the impression I got) then yeah, two versions is your best bet.
|
Thu Aug 27, 2009 12:59 am |
|
|
|