Author |
Message |
Gotcha!
Joined: Tue Apr 01, 2008 4:49 pm Posts: 1972 Location: The Netherlands
|
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.
|
Sun Jun 05, 2011 11:00 pm |
|
|
Coops
Joined: Wed Feb 17, 2010 12:07 am Posts: 1545 Location: That small peaceful place called Hell.
|
Re: Added guns to dropship: Guns then shoot down dropship
try adding Code: self.turret.Team = self.Team
|
Sun Jun 05, 2011 11:03 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Added guns to dropship: Guns then shoot down dropship
Or if that doesn't work, use SetWhichMONotToHit.
|
Sun Jun 05, 2011 11:09 pm |
|
|
Mehman
Joined: Tue Nov 17, 2009 7:38 pm Posts: 909 Location: France
|
Re: Added guns to dropship: Guns then shoot down dropship
or try ToActor(self.turret).Team = self.Team it may work...or not
|
Sun Jun 05, 2011 11:10 pm |
|
|
Gotcha!
Joined: Tue Apr 01, 2008 4:49 pm Posts: 1972 Location: The Netherlands
|
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.
|
Sun Jun 05, 2011 11:32 pm |
|
|
Coops
Joined: Wed Feb 17, 2010 12:07 am Posts: 1545 Location: That small peaceful place called Hell.
|
Re: Added guns to dropship: Guns then shoot down dropship
where did you add it?
|
Sun Jun 05, 2011 11:34 pm |
|
|
Gotcha!
Joined: Tue Apr 01, 2008 4:49 pm Posts: 1972 Location: The Netherlands
|
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;
|
Sun Jun 05, 2011 11:50 pm |
|
|
Xery
Joined: Sat Feb 26, 2011 10:29 am Posts: 163
|
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.
|
Mon Jun 06, 2011 4:41 am |
|
|
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
|
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; That sets the team variable of the table called "Turret" rather than the actual turrets stored in the table, and therefore does nothing. You probably want to do it something like this: 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
|
Mon Jun 06, 2011 6:53 am |
|
|
Gotcha!
Joined: Tue Apr 01, 2008 4:49 pm Posts: 1972 Location: The Netherlands
|
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.
|
Mon Jun 06, 2011 12:29 pm |
|
|
|