|
Page 1 of 1
|
[ 12 posts ] |
|
ACrabs and their silly antics
Author |
Message |
Shook
Joined: Fri Feb 16, 2007 8:43 pm Posts: 1695 Location: AH SHIT FUCK AUGH
|
ACrabs and their silly antics
So yeah, been trying to make a turret that orients itself according to a nearby wall. While i miraculously managed to get the script fully functional, there's one little caveat. First, you place turrets on all four sides of a square. Then, the bottom one explodes. WHY? Is this some ridiculous hard-coded shenanigans by Data, and/or is there any way to bypass it? I guess i could just play around with the sprite and some Frame trickiness, but it'd be lovely if i (or anyone else) didn't have to, since it probably involves another few hours of intense raging.
|
Wed Oct 26, 2011 9:56 pm |
|
|
Gotcha!
Joined: Tue Apr 01, 2008 4:49 pm Posts: 1972 Location: The Netherlands
|
Re: ACrabs and their silly antics
Bizarre. Does it only happen when you place them like that? What if you put more space inbetween them? O_o
|
Wed Oct 26, 2011 9:59 pm |
|
|
Shook
Joined: Fri Feb 16, 2007 8:43 pm Posts: 1695 Location: AH SHIT FUCK AUGH
|
Re: ACrabs and their silly antics
Happens if you omit the three others entirely as well, so i doubt it's a case of interaction between the turrets. ¯\(°_o)/¯
|
Wed Oct 26, 2011 10:11 pm |
|
|
Gotcha!
Joined: Tue Apr 01, 2008 4:49 pm Posts: 1972 Location: The Netherlands
|
Re: ACrabs and their silly antics
What the hell... Well, I guess 4 makes a crowd. >_> Maybe you can post your secret stuff here so great brainy minds can take a look at it?
|
Wed Oct 26, 2011 10:37 pm |
|
|
Azukki
Joined: Sat Nov 03, 2007 9:44 pm Posts: 1916 Location: Flint Hills
|
Re: ACrabs and their silly antics
I'm guessing hardcoded shenanigans. Maybe instead of putting the ACrab upsidedown to mount it to the top, give it a second sprite frame for upward mounting?what the hell I've been skipping lines of text at random all day aghThe frame thing really shouldn't be that hard at all. Just change self.Frame to 2 or whatever when you detect upward mounting, which you seem to already have taken care of. Also, you've probably have noticed this enough yourself already, but the mountings are sunk into the modules to varying degrees, and it'd look better if you avoided that. That is, assuming you have that module pictured on the grid and not moved slightly off it.
|
Wed Oct 26, 2011 10:44 pm |
|
|
Shook
Joined: Fri Feb 16, 2007 8:43 pm Posts: 1695 Location: AH SHIT FUCK AUGH
|
Re: ACrabs and their silly antics
Aye, that's true. I believe i have an idea to fix that, though. Also, count on me to forget the critical details. Here's the used Lua: Code: function Create(self) local checkRange = 50; for i=0, 3 do local angle = (math.pi/2)*i; self.endPos = Vector(0,0); local wallCheck = SceneMan:CastStrengthRay(self.Pos, Vector(checkRange,0):RadRotate(angle), 1, self.endPos, 0, 128, true); local dist = SceneMan:ShortestDistance(self.endPos, self.Pos, true).Magnitude; print(dist); if dist ~= nil then if self.oldDist == nil then self.closest = i; self.oldDist = dist; self.lastPos = self.endPos; else if self.oldDist > dist then self.closest = i; self.oldDist = dist; self.lastPos = self.endPos; end end end end print(self.closest); print(self.lastPos); if self.closest ~= nil and self.oldDist < 50 then self.RotAngle = (math.pi/2)*self.closest; self.Pos = self.lastPos + Vector(self.SpriteOffset.X,0):RadRotate(self.RotAngle); end self.PinStrength = 999; end
function Update(self) if self.lastPos ~= nil and self.oldDist < 50 then self.RotAngle = (math.pi/2)*self.closest; self.Pos = self.lastPos + Vector(self.SpriteOffset.X,0):RadRotate(self.RotAngle); end self.HFlipped = false; end In a nutshell, it starts out by casting 4 rays in the cardinal directions, then finding out which one is closest. Then it uses that information to set an appropriate RotAngle, so that the base of the turret faces the wall, and then pins the everloving ♥♥♥♥ out of it. I realized another oddity though; the base faces right on the sprite ( O-| ), so technically the bottom one isn't upside-down, the rightmost one is. Maybe they don't like being turned more than 180 degrees? Don't know if that's the case at all, since i'm not sure which way the CC angles go (counter-clockwise in reality), but maybe they go clockwise since the Y-axis is inverted? Edit: This just in, CC angles go counter-clockwise. That means that it's the 90-degree turret that explodes. ¯\(°_o)/¯
Attachments:
Turret.lua [1.12 KiB]
Downloaded 196 times
|
Thu Oct 27, 2011 12:21 pm |
|
|
jimbo8098
Joined: Sun Aug 07, 2011 11:53 pm Posts: 11
|
Re: ACrabs and their silly antics
does it happen if you just place the bottom one?
|
Thu Oct 27, 2011 2:40 pm |
|
|
Shook
Joined: Fri Feb 16, 2007 8:43 pm Posts: 1695 Location: AH SHIT FUCK AUGH
|
Re: ACrabs and their silly antics
Yup. In any case, i'm turning to the sprite-y approach now, but a definite conclusion to this would still be awesome. I mean really, it explodes when turned 90 degrees, but not 0, 180 or 270? Something's off here. Maybe it's trying to right itself up, but is prevented by the pinning, and thus accumulating enough impulse to explode it?
|
Thu Oct 27, 2011 3:25 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: ACrabs and their silly antics
Try disabling the AI and see if that stops it from bugging out on you.
|
Thu Oct 27, 2011 3:34 pm |
|
|
Shook
Joined: Fri Feb 16, 2007 8:43 pm Posts: 1695 Location: AH SHIT FUCK AUGH
|
Re: ACrabs and their silly antics
How do? ¯\(°_o)/¯ The hard-coded AI doesn't seem to give a ♥♥♥♥ about me disabling it. Anyhoo, the spritey approach is working nicely, and was easier than i expected (aside from fixing a million offsets). No random explodage any more, now i just have to worry about the AI being extremely eager to flip it horizontally. Which would look dumb.
This is more of a Lua question, but is it at all possible to prevent it from trying to flip? I know i can do HFlipped = false all the time, but it still flips both weapon and attachables. It would also be lovely if the player couldn't do that either, since it looks and feels silly.
|
Thu Oct 27, 2011 5:26 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: ACrabs and their silly antics
Set the left/right control to be false all the time. Shook wrote: The hard-coded AI doesn't seem to give a ♥♥♥♥ about me disabling it. Can you not use the old self.AIMode = 0 on it?
|
Thu Oct 27, 2011 5:36 pm |
|
|
Shook
Joined: Fri Feb 16, 2007 8:43 pm Posts: 1695 Location: AH SHIT FUCK AUGH
|
Re: ACrabs and their silly antics
Nope, it's like a honey badger in that regard. I'll try that controller stuff though, hopefully it'll work.
|
Thu Oct 27, 2011 5:44 pm |
|
|
|
|
Page 1 of 1
|
[ 12 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
|
|