View unanswered posts | View active topics It is currently Tue Jul 16, 2019 7:30 am

 Page 1 of 1 [ 10 posts ]
 Print view Previous topic | Next topic
Added guns to dropship: Guns then shoot down dropship
Author Message

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1966
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");
self.Turret[1].Offset = Vector(25,25);
self.Turret[2] = CreateACrab("Raptor Gun Mini");
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

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

Code:
self.turret.Team = self.Team

Sun Jun 05, 2011 11:03 pm
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

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

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1966
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

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

Sun Jun 05, 2011 11:34 pm

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1966
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

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
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

self.Turret[2] = CreateACrab("Raptor Gun Mini")
self.Turret[2].Offset = Vector(-25,25)
self.Turret[2].Team = self.Team
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

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1966
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 10 posts ]

#### Who is online

Users browsing this forum: No registered users

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Cortex Command    Dev Log    Wiki    Game Discussion    Game and Licensing Support    Mod Making       Lua Scripting       Requests    Mod Releases       Older Mods    Scene Releases       Scene Making Planetoid Pioneers    Game Discussion    Pioneer Program Lounge Data Realms Off-Topic    Off Topic Chat       Gaming       Forum Games    Site Support & Feedback