View unanswered posts | View active topics It is currently Thu Jan 17, 2019 1:56 am

Reply to topic  [ 1 post ] 
 Multi-Engine Dropships (as in - more than 2) 
Author Message
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2061
Reply with quote
Post Multi-Engine Dropships (as in - more than 2)
So I was at this over 8 years ago here:
And I couldn't get this to work back then.

I honestly don't know if anybody attempted this after that and succeeded, because I couldn't find anything of the like, or if this is relevant or of any use to anyone.
I also don't know where this urge to come back to CC modding came from but anyway.

I have (questionably) solid results.
Don't mind the sprites they are placeholders, this is a proof of concept.

Image Image
(disappearing engine flash on the extra engines is me using a cutoff button to shut them off)

This proved to be a real headache, the original method was very complicated and didn't seem to work.
In the original method back then I attempted to manipulate the engines from a script that is run by the hull, i've learned that:
1. .ini attached AEmitters do not show up in MOID view (also MOID view drop my CC to 5fps for whatever reason).
2. .ini attached AEmitters don't even show up while you are in scene editor mode, they only appear after the DS is placed. They do appear just fine in actor editor.
3. None of the attachable accesses hacks (that I tried) seem to pick up these attached AE's.
4. Existence is pain.

Back then, my engine was attached to an attachable wing, this time I tried doing the same thing all over again by attaching the engine directly to the hull and it didn't work exactly the same.
Mind that in this very long time period my understanding of lua and the magic behind it did not improve, nor was it very impressive back then.

Now, I don't know if adding scripts to AEmitters was possible back then, but this was the breakthrough that made this possible now.
I ran a small script off the secondary engine that picks up a button and cuts off the emission and it magically worked.

Next I attempted to access the dropship hull and it's original engines from my attached engines - this method failed for me but this is most likely because i'm bad at this stuff.
So what I did is I ran a script on the hull that access the original engines and stores their "RotAngle" and "Throttle" values in global variables.
After that the script on the attached engines picks up these global variables and applies them and everything magically works.

I've learned from this that "Throttle" is not a read-only value and can be directly modified by using "ToAEmitter(self).Throttle = #;" (# being between 1 (max thrust) to -1 (min thrust)).
I've also learned that copying the throttle value over to my attached engine did not affect the scale of the flash like it does with the original engines so you have no visual representation of min/max throttle.
So while you do get proper throttle on your engines, the flash looks as if you are at 100%.

As you can see, this method does not limit the amount of engines you can slap on you DS, you can add as many as you like.
The limiting factor is the GibImpulseLimit on your hull, so adding more engines without upping GIL will cause your DS to instagib.

So this works nice and dandy but you can't have more than one of these on scene because it uses global values and they get overwritten and all sorts of crazy crap starts to happen. No crashing though.
Another minor issue is that while you are in scene editor and you select the DS (just select, don't place) the console will spam this:


As soon as you place it into the scene the spam stops.
This is actually very weird because in the translucent state prior to being placed, the attached engines are not showing but the script is already running.
If you are in actor editor and select the DS it will spam indefinitely.

I leave this here now in hopes of someone better at lua that me is able to refine this by ditching the global variables or at least making them independent to each DS so they don't overlap.

Here's the code:

function Create(self)
   engineThrottle = nil;
   engineAngle = nil;
   engineCutoff = nil;

function Destroy(self)
   engineThrottle = nil;
   engineAngle = nil;
   engineCutoff = nil;

function Update(self)
   for i = 1, MovableMan:GetMOIDCount()-1 do
      self.engine = MovableMan:GetMOFromID(i);
      if self.engine.PresetName == "Test Engine Pri" and self.engine.ClassName == "AEmitter" and self.engine.RootID == self.RootID then
         engineAngle = self.engine.RotAngle;
         engineThrottle = ToAEmitter(self.engine).Throttle;
--         print("engine");
--         print(engineAngle);
--         print(engineThrottle);
-- press CROUCH button to turn off engines, release to turn on.
   if (self:IsPlayerControlled()) and self:GetController():IsState(Controller.BODY_CROUCH) == true then
      engineCutoff = 1;
   elseif (self:IsPlayerControlled()) and self:GetController():IsState(Controller.BODY_CROUCH) == false then
      engineCutoff = 0;

function Create(self)
--   ToAEmitter(self):EnableEmission(true);

function Update(self)
   self.RotAngle = engineAngle;
   ToAEmitter(self).Throttle = engineThrottle;
   if engineCutoff == 1 then
   elseif engineCutoff == 0 then

Here's the .rte
DSTest.rte.rar [6.13 KiB]
Downloaded 10 times


Here's an easier-on-the-eye preview.


Sat Dec 22, 2018 11:46 am
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

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.020s | 14 Queries | GZIP : Off ]