View unanswered posts | View active topics It is currently Sat Dec 14, 2019 4:54 pm



Reply to topic  [ 10 posts ] 
 Added guns to dropship: Guns then shoot down dropship 
Author Message
User avatar

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1966
Location: The Netherlands
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post 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
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1966
Location: The Netherlands
Reply with quote
Post 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
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Added guns to dropship: Guns then shoot down dropship
where did you add it?


Sun Jun 05, 2011 11:34 pm
Profile
User avatar

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1966
Location: The Netherlands
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Feb 26, 2011 10:29 am
Posts: 163
Reply with quote
Post 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
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1966
Location: The Netherlands
Reply with quote
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.041s | 15 Queries | GZIP : Off ]