View unanswered posts | View active topics It is currently Fri Apr 26, 2024 4:19 pm



Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4  Next
 Detached attachables being deleted 
Author Message
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Detached attachables being deleted
You need a combination of set which MO not to hit and trigonometry.


Sat Jun 12, 2010 1:19 pm
Profile WWW
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Detached attachables being deleted
411570N3 wrote:
You need a combination of set which MO not to hit and trigonometry.

I'm not very bright in lua, or math tbh. >___>'


Sat Jun 12, 2010 1:29 pm
Profile
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Detached attachables being deleted
I might give the maths a shot later, if the other people in the thread already helping you haven't done it in a period of time.
EDIT: Actually, I might give it a shot now.
You'd need to change this
Code:
         if secjets.PresetName == "Heavy Drop Ship Secondary Engine Left" then
            self.secjetL.Pos.X = self.Pos.X - 100;
            self.secjetL.Pos.Y = self.Pos.Y + 4;
         elseif secjets.PresetName == "Heavy Drop Ship Secondary Engine Right" then
            self.secjetR.Pos.X = self.Pos.X + 100;
            self.secjetR.Pos.Y = self.Pos.Y + 4;
To something like this, but with proper syntax (assuming mine's wrong)
Code:
         if secjets.PresetName == "Heavy Drop Ship Secondary Engine Left" then
            self.secjetL.Pos.X = cos(self.rotation)*-100 + self.pos.x;
            self.secjetL.Pos.Y = sin(self.rotation)*-100 + 4 + self.pos.y;
         elseif secjets.PresetName == "Heavy Drop Ship Secondary Engine Right" then
            self.secjetR.Pos.X = cos(self.rotation)*100 + self.pos.x;
            self.secjetR.Pos.Y = sin(self.rotation)*100 + 4 + self.pos.y;


Sat Jun 12, 2010 1:32 pm
Profile WWW
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post Re: Detached attachables being deleted
Just use

Code:
Thruster.Pos = self.Pos + Vector(math.cos(self.RotAngle)*DesiredDistance,math.sin(self.RotAngle)*-(DesiredDistance));


To make 'em rotate around the ship (Replace DesiredDistance with how far you want them to be from the ship), and a RotAngle check on the real thrusters to make them rotate around their own axis.

Heck, ninja'd!


Sat Jun 12, 2010 6:44 pm
Profile WWW
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Detached attachables being deleted
Thanks guys i'll try these out when I get back working on this goddamn thing.


Sat Jun 12, 2010 10:30 pm
Profile
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post Re: Detached attachables being deleted
Oh, and make sure to add the ship's rotangle to the thruster's, or it'll rotate weirdly.


Sat Jun 12, 2010 11:48 pm
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Detached attachables being deleted
Ew, math.

Code:
self.engineoffsetL = Vector(50,23); -- Where do you want the engine to go
self.engineL.Pos = self.Pos + (self.engineoffset:RadRotate(self.RotAngle));
self.engineL.RotAngle = self.shipengineL.RotAngle;
self.engineL.Vel = self.Vel;


Info:
"self.engineL" should be a pointer to the Lua attached object.
"self.shipengineL" is a pointer to the actual ship engine.
"self.engineoffsetL" is the offset for the engine.

You need to do of those, one for each Lua'd engine.


Sun Jun 13, 2010 2:29 am
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Detached attachables being deleted
CaveCricket48 wrote:
Ew, math.

Code:
self.engineoffsetL = Vector(50,23); -- Where do you want the engine to go
self.engineL.Pos = self.Pos + (self.engineoffset:RadRotate(self.RotAngle));
self.engineL.RotAngle = self.shipengineL.RotAngle;
self.engineL.Vel = self.Vel;


Info:
"self.engineL" should be a pointer to the Lua attached object.
"self.shipengineL" is a pointer to the actual ship engine.
"self.engineoffsetL" is the offset for the engine.

You need to do of those, one for each Lua'd engine.


Alright, i'll try that.
Also, tell me, is it possible to access the engine's throttle values (When working) and apply them to the extra engines?


Sun Jun 13, 2010 12:55 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Detached attachables being deleted
According to the wiki, the property "GetThrottle" is a scalar value that checks the emitter's throttle. Not sure if you can set the throttle value or not.


Sun Jun 13, 2010 4:57 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Detached attachables being deleted
CaveCricket48 wrote:
According to the wiki, the property "GetThrottle" is a scalar value that checks the emitter's throttle. Not sure if you can set the throttle value or not.

No 'SetThrottle', or 'self.Throttle'?
Gee that sucks.


Sun Jun 13, 2010 5:38 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Detached attachables being deleted
So I used this:
Code:
self.engineoffsetL = Vector(50,23); -- Where do you want the engine to go
self.engineL.Pos = self.Pos + (self.engineoffset:RadRotate(self.RotAngle));
self.engineL.RotAngle = self.shipengineL.RotAngle;
self.engineL.Vel = self.Vel;

Except it looks more like this:
Code:
for i = 1,MovableMan:GetMOIDCount()-1 do
self.jet = MovableMan:GetMOFromID(i);
if self.jet.PresetName == "Heavy Drop Ship Engine Left" and self.jet.ClassName == "AEmitter" and self.jet.RootID == self.ID then
self.engineoffsetL = Vector(-100,4);
self.secjetL.Pos = self.Pos + (self.engineoffsetL:RadRotate(self.RotAngle));
self.secjetL.RotAngle = self.jet.RotAngle;
self.secjetL.Vel = self.Vel;

Everything seems to be working, but there are 2 issues:

1. DS is unstable as ♥♥♥♥ due to this whole lua attaching (Wasn't unstable with regular attaching...)
2. Secondary jets are drawn under the dropship's wings, don't want that. Need them to be drawn over.

Current code:
Code:
function Create(self)
   self.secjetL = nil;
   self.secjetL = CreateAEmitter("Heavy Drop Ship Secondary Engine Left");
   self.secjetL.Pos.X = self.Pos.X - 100;
   self.secjetL.Pos.Y = self.Pos.Y + 4;
   MovableMan:AddParticle(self.secjetL);
   self.secjetR = nil;
   self.secjetR = CreateAEmitter("Heavy Drop Ship Secondary Engine Right");
   self.secjetR.Pos.X = self.Pos.X + 100;
   self.secjetR.Pos.Y = self.Pos.Y + 4;
   MovableMan:AddParticle(self.secjetR);
end

function Update(self)      
   local curdist = 250;
   for secjets in MovableMan.Particles do
      local avgx = secjets.Pos.X - self.Pos.X;
      local avgy = secjets.Pos.Y - self.Pos.Y;
      local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
      if dist < curdist then
         if secjets.PresetName == "Heavy Drop Ship Secondary Engine Left" then
            for i = 1,MovableMan:GetMOIDCount()-1 do
               self.jet = MovableMan:GetMOFromID(i);
               if self.jet.PresetName == "Heavy Drop Ship Engine Left" and self.jet.ClassName == "AEmitter" and self.jet.RootID == self.ID then
                  self.engineoffsetL = Vector(-100,4);
                  self.secjetL.Pos = self.Pos + (self.engineoffsetL:RadRotate(self.RotAngle));
                  self.secjetL.RotAngle = self.jet.RotAngle;
                  self.secjetL.Vel = self.Vel;
               end
            end
         elseif secjets.PresetName == "Heavy Drop Ship Secondary Engine Right" then
            for i = 1,MovableMan:GetMOIDCount()-1 do
               self.jet = MovableMan:GetMOFromID(i);
               if self.jet.PresetName == "Heavy Drop Ship Engine Right" and self.jet.ClassName == "AEmitter" and self.jet.RootID == self.ID then
                  self.engineoffsetR = Vector(100,4);
                  self.secjetR.Pos = self.Pos + (self.engineoffsetR:RadRotate(self.RotAngle));
                  self.secjetR.RotAngle = self.jet.RotAngle;
                  self.secjetR.Vel = self.Vel;
               end
            end
         end
      end
   end
   if (self:IsPlayerControlled()) and self:GetController():IsState(Controller.BODY_CROUCH) then
      self.Holding = 1;
   else
      self.Holding = nil;
   end
   if self.Holding == 1 then
      local detacher = nil;
      detacher = CreateMOPixel("Wing Detacher");
      detacher.Pos.X = self.Pos.X;
      detacher.Pos.Y = self.Pos.Y;
      MovableMan:AddParticle(detacher);
   end
end


How fix?

Edit:

Yeah the whole lua attaching method is really glitchy... Like, really...
There must be a way to get it work with regular attaching.


Wed Jun 16, 2010 3:51 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Detached attachables being deleted
When you created the emitters in the Create() function you already had a pointer to them. You don't need to get a second pointer to them, that's pointless. (no pun intended)


Wed Jun 16, 2010 5:53 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Detached attachables being deleted
CaveCricket48 wrote:
When you created the emitters in the Create() function you already had a pointer to them. You don't need to get a second pointer to them, that's pointless. (no pun intended)


Oh, I see.
But that doesn't fix the main issues.


Wed Jun 16, 2010 6:59 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Detached attachables being deleted
What do you mean by the DS being unstable?


Wed Jun 16, 2010 7:01 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Detached attachables being deleted
Draw order is also semi-unfixable.

It's a result of the engine automatically drawing actors (and their attachables) over anything that's in the MOSRotating class.

The only (bad) fix is to make each of your pseudo-attachables unhittable Actor-class actors.

Which is not really worth it.

And if it's unstable, then there's something wrong with your position.


Wed Jun 16, 2010 8:03 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 49 posts ]  Go to page Previous  1, 2, 3, 4  Next

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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.412s | 15 Queries | GZIP : Off ]