Data Realms Fan Forums http://45.55.195.193/ |
|
Preventing an ACrab from turning http://45.55.195.193/viewtopic.php?f=1&t=18277 |
Page 1 of 1 |
Author: | Petethegoat [ Mon Mar 29, 2010 5:29 pm ] |
Post subject: | Preventing an ACrab from turning |
Well, as the title would suggest, I'm looking for a way to stop an ACrab from being able to turn around. So far I've tried using CaveCricket's 'prevent people leaping out of windows' script with the fluff ripped out, and I've had a look at the braincase, which won't work, as I can't put a turret on it. Is this even possible, short of using a dropship? If it matters at all, I'm making a stationary coastal gun style emplacement that I don't want to turn around. |
Author: | Grif [ Mon Mar 29, 2010 5:40 pm ] |
Post subject: | Re: Preventing an ACrab from turning |
function Create(self) self.flipped == self.HFlipped; end function Update(self) if self.HFlipped ~= self.flipped then self.HFlipped = self.flipped; end end |
Author: | Petethegoat [ Mon Mar 29, 2010 6:04 pm ] |
Post subject: | Re: Preventing an ACrab from turning |
Partially working, but it only works if the player/AI isn't actively trying to turn around. Anything you can do about that? |
Author: | Grif [ Mon Mar 29, 2010 6:16 pm ] |
Post subject: | Re: Preventing an ACrab from turning |
Hmm. You could check if the actor is getting a move command opposite of the facing direction, and try to cancel it, but I'm not sure if that'd work any better when a real player's using it. |
Author: | Abdul Alhazred [ Mon Mar 29, 2010 7:19 pm ] |
Post subject: | Re: Preventing an ACrab from turning |
The barrel is independent of the actor. Try modifying this script. |
Author: | Petethegoat [ Mon Mar 29, 2010 7:41 pm ] |
Post subject: | Re: Preventing an ACrab from turning |
The unit in question doesn't need to move, if that helps at all. Abdul, which parts do I need to be looking at? Would I be right in thinking that I want to change the RotAngle bits into HFlips? Ok, I just tried that, and I have some pretty odd results. Time for a spot of debugging, I think. Code: function Create(self) self.flipped = self.HFlipped; -- Find the gun for i = 1, MovableMan:GetMOIDCount()-1 do if MovableMan:GetRootMOID(i) == self.ID then -- an obj without a parent has ID == RootID self.Gun = MovableMan:GetMOFromID(i) if self.Gun.ClassName == "HDFirearm" then self.Gun = ToAttachable(self.Gun) break end end end end function Update(self) self:GetController():SetState(Controller.MOVE_RIGHT,false); self:GetController():SetState(Controller.MOVE_LEFT,false); if self.HFlipped ~= self.flipped then self.HFlipped = self.flipped; if self.Gun:IsAttached() then -- Restrict aiming: from 0.3 rad below horizon and above / lies if self.HFlipped then if self.Gun.HFlipped ~= self.flipped then self.Gun.HFlipped = self.flipped end end end end end This is what I have. The problems are as follows: Turrets that face right act as without your script; that is, they can still turn around if the player tries to, but do correct themselves otherwise. Turrets that face left that try to turn right fail horribly. Nothing flips, but the gun is on the right (handed) side of the base, the sharpaim points left, but the gun fires right. Hopefully I described that decently. |
Author: | Abdul Alhazred [ Mon Mar 29, 2010 7:55 pm ] |
Post subject: | Re: Preventing an ACrab from turning |
Sounds messy, have you tried rotating the barrel by pi instead of flipping? Also, in my experience sharp aiming will always override lua but you could try setting sharp aim to false when facing the wrong direction using SetState. The AI's aim will most likely be screwed up, shooting in the opposite direction, but perhaps you can solve that by manually setting the ViewPoint every frame. |
Author: | Petethegoat [ Mon Mar 29, 2010 8:32 pm ] |
Post subject: | Re: Preventing an ACrab from turning |
I've been looking at the Wiki for about half an hour, and I have no idea how to do any of that. Here is a picture for clarification purposes: Odd, no? |
Author: | Abdul Alhazred [ Tue Mar 30, 2010 8:02 am ] |
Post subject: | Re: Preventing an ACrab from turning |
Try this: Code: function Create(self) self.flipped = self.HFlipped self.Ctrl = self:GetController() -- Find the gun local thisID = self.ID for i = 1, MovableMan:GetMOIDCount()-1 do if MovableMan:GetRootMOID(i) == thisID then -- an obj without a parent has ID == RootID self.Gun = MovableMan:GetMOFromID(i) if self.Gun.ClassName == "HDFirearm" then self.Gun = ToAttachable(self.Gun) break end end end end function Update(self) if self.flipped ~= self.HFlipped then self.HFlipped = not self.HFlipped if self.Gun and self.Gun:IsAttached() then self.ViewPoint = self.Pos self.Gun.HFlipped = self.flipped self.Ctrl:SetState(Controller.AIM_SHARP, false) self.Ctrl:SetState(Controller.WEAPON_FIRE, false) if self.flipped ~= self.Gun.HFlipped then self.ViewPoint = self.Pos else self.Gun.RotAngle = 0 end end end end This is not tested so I cannot guarantee you it will work. |
Author: | Petethegoat [ Tue Mar 30, 2010 11:17 am ] |
Post subject: | Re: Preventing an ACrab from turning |
Ahh thanks, looks better. Sadly I'm not in a position to test it at the moment, but I'll report back as soon as I get home. Edit: I've tested it, and it is nearly perfect, the main issue now being that the turret still does move to the other side of the base, though it can no longer shoot or sharpaim when aiming that way. Otherwise, the only problem is that the wounds still flip on both the base and turret. Would I be right in thinking that it's impossible to fix them? Hmm. Is it possible to turn off aiming all together? Could you try stopping all aiming when HFlip = 1? |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |