Data Realms Fan Forums http://45.55.195.193/ |
|
Added guns to dropship: Guns then shoot down dropship http://45.55.195.193/viewtopic.php?f=73&t=24129 |
Page 1 of 1 |
Author: | Gotcha! [ Sun Jun 05, 2011 11:00 pm ] |
Post subject: | Added guns to dropship: Guns then shoot down dropship |
Hello people, Probably a really easy question for you brainiacs. I had this old script lying around. I think Abdul originally created it, for which I have my thanks. I used it to put two turrets/guns onto a dropship. Code: function Create(self) self.Turret = {}; self.Turret.Team = 0; self.Turret[1] = CreateACrab("Raptor Gun Mini"); MovableMan:AddParticle(self.Turret[1]); self.Turret[1].Offset = Vector(25,25); self.Turret[2] = CreateACrab("Raptor Gun Mini"); MovableMan:AddParticle(self.Turret[2]); self.Turret[2].Offset = Vector(-25,25); end function Destroy(self) for i = 1, #self.Turret do if MovableMan:IsParticle(self.Turret[i]) == true then if self.Health < 1 then self.Turret[i]:GibThis() else self.Turret[i].ToDelete = true end end end end function Update(self) if self.AngularVel > 0.45 and self.RotAngle > 0.45 then self.AngularVel = 0.45; elseif self.AngularVel < -0.45 and self.RotAngle < -0.45 then self.AngularVel = -0.1; end for i = 1, #self.Turret do if MovableMan:IsParticle(self.Turret[i]) == true then self.Turret[i].Vel.X = 0; self.Turret[i].Vel.Y = 0; self.Turret[i].RotAngle = self.RotAngle; self.Turret[i].Pos = self.Pos + self:RotateOffset(self.Turret[i].Offset) end end end All works fine, except the turrets shoot down the dropship they're attached to. (Fun to watch.) Even if I change "self.Turret.Team = 0" to "self.Turret.Team = 1", which would be the red team. Does anyone know how to modify this script so that the turrets only fire at enemies? Or perhaps someone has a much better script for this kind of action? Any help is greatly appreciated. |
Author: | Coops [ Sun Jun 05, 2011 11:03 pm ] |
Post subject: | Re: Added guns to dropship: Guns then shoot down dropship |
try adding Code: self.turret.Team = self.Team |
Author: | Roast Veg [ Sun Jun 05, 2011 11:09 pm ] |
Post subject: | Re: Added guns to dropship: Guns then shoot down dropship |
Or if that doesn't work, use SetWhichMONotToHit. |
Author: | Mehman [ Sun Jun 05, 2011 11:10 pm ] |
Post subject: | Re: Added guns to dropship: Guns then shoot down dropship |
or try ToActor(self.turret).Team = self.Team it may work...or not |
Author: | Gotcha! [ Sun Jun 05, 2011 11:32 pm ] |
Post subject: | Re: Added guns to dropship: Guns then shoot down dropship |
@Coops9753: Done. No difference though. @Roast Veg: No idea what to do with that, sorry. @Mehman: That gives an error and removes the guns. |
Author: | Coops [ Sun Jun 05, 2011 11:34 pm ] |
Post subject: | Re: Added guns to dropship: Guns then shoot down dropship |
where did you add it? |
Author: | Gotcha! [ Sun Jun 05, 2011 11:50 pm ] |
Post subject: | Re: Added guns to dropship: Guns then shoot down dropship |
I removed the line Code: self.Turret.Team = 0; and replaced it with Code: self.Turret.Team = self.Team; |
Author: | Xery [ Mon Jun 06, 2011 4:41 am ] |
Post subject: | Re: Added guns to dropship: Guns then shoot down dropship |
Code: SetWhichMOToNotHit Sets this MO to not hit a specific other MO and all its children even though MO hitting is enabled on this MovableObject Arguments: A pointer to the MO to not be hitting. 0 means don't ignore anyhting. Ownership is not transferred! For how long, in S, to ignore the above. Negative number means forever. In general: self.bullet:SetWhichMOToNotHit(self.shooter,-1); In that case, you need to shoot bullets by lua, or check when fire, find the bullet then set it not to hit the parent. that sucks. Maybe you can try like: self.ship:SetWhichMOToNotHit(self.gun,-1); I'm not sure if it works. |
Author: | Abdul Alhazred [ Mon Jun 06, 2011 6:53 am ] |
Post subject: | Re: Added guns to dropship: Guns then shoot down dropship |
Gotcha! wrote: I removed the line Code: self.Turret.Team = 0; and replaced it with Code: self.Turret.Team = self.Team; Code: function Create(self) self.Turret = {} self.Turret[1] = CreateACrab("Raptor Gun Mini") self.Turret[1].Offset = Vector(25,25) self.Turret[1].Team = self.Team MovableMan:AddParticle(self.Turret[1]) self.Turret[2] = CreateACrab("Raptor Gun Mini") self.Turret[2].Offset = Vector(-25,25) self.Turret[2].Team = self.Team MovableMan:AddParticle(self.Turret[2]) end The script looks like a variant of AaronLee's Superheavy dropship btw: viewtopic.php?p=203454#p203454 |
Author: | Gotcha! [ Mon Jun 06, 2011 12:29 pm ] |
Post subject: | Re: Added guns to dropship: Guns then shoot down dropship |
You are a lifesaver, Abdul. That works like a charm! Thanks to everyone for helping me out. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |