May 19, 2024, 02:54:37

Author Topic: Working around the ship limit finally possible?  (Read 9798 times)

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
Working around the ship limit finally possible?
« on: December 02, 2010, 02:23:49 »
Thanks to Mularac's question about making wrecked ships appear in a mission I may have stumbled upon something awesome:
  • If you create a new ship with CreateShip(), it'll count against the ship limit
  • It'll still count, if you set the behaviour to 4 afterwards, making it an "asteroid" from the game's perspective
  • It'll not count anymore, if you make it leave the scene by calling Disappear() on it
  • It'll still not count, if you make it reappear later or immedeately by calling Appear() on it (it'll still behave like an asteroid/wreck, though)
  • And now the magic: It'll still not count, if you set its behaviour back to 0, to make it usable as a ship again
I just created around 50 Fenris-class cruisers and successfully ordered all of them to move somewhere - worked like a charm, although the performance wasn't all that great... but that's not the point. Using that trick we could finally be able to make missions involving much more than just the standard 20-something ships until the game crashes.

Really wonderful for something like my experimental warfare mini-mod, where by using that technique you could "build" truly massive fleets in-game without making the game crash so soon. :)

I obviously haven't done a lot of testing, though. The game may bug out in certain situations with this many ships present - only prolonged testing will tell, if it's really a viable path to take. In any case, here's a quick code snippet to spawn a ship that way:

Code: [Select]
RULE event Cheat1
:action
// calculate random spawn position and spawn ship
E.newShipPosition := VMul(Rnd() * 3000, VRandomDir());
E.newShip := CreateShip(#styp_gtc_fenris, #race_player, "DynamicShip");
PutShip(E.newShip, E.newShipPosition, 0, 0, 0, 0, 0);

// make ship visible to player
MakeFullyKnown(E.newShip);
FreezeReconState(E.newShip, 1);

// make ship behave like an asteroid, disappear/appear and return back to normal
E.newShip:behaviour := 4;
E.disappearedShip := Disappear(E.newShip);
Appear(E.disappearedShip);
E.newShip:behaviour := 0;

// debug stuff - print the number of spawned ships in console
count := count + 1;
Debug("created ship", count);
:end
END
« Last Edit: December 08, 2010, 12:16:10 by Arparso »

Offline Lt.Brandon

  • Crewman
  • *
  • Posts: 39
  • Karma: 0
  • FIRE ZE MISSILEZ!
    • View Profile
    • War of The Damned MODDB Page
(No subject)
« Reply #1 on: December 02, 2010, 11:01:36 »
I find this interesting, but do the ships show on the UI selection area if they are on the players team?

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #2 on: December 02, 2010, 11:08:23 »
Yeah, they do - just like regular ships.

Offline Lt.Brandon

  • Crewman
  • *
  • Posts: 39
  • Karma: 0
  • FIRE ZE MISSILEZ!
    • View Profile
    • War of The Damned MODDB Page
(No subject)
« Reply #3 on: December 02, 2010, 11:21:22 »
That's nice to know, and now that I think about it I did need a bit more then the nexus ship limit for some later missions. The last few missions I have planned have a rather large(Aka HUGE[And I mean HUGE]) battle with multiple pirate fleets etc.

Off Topic
I have yet to get the skirmisher to work with my mod. I've tried a lot of things, but nothing seems to have any affect on it, I don't even get an error when it crashes it just closes. I know the problem is related to the tacticstypes.ini, however, nothing I did worked  :(

List of things I tried(That I remember doing at least)
Removing and re-adding ships/devices(Didn't get me anywhere with the skirmisher, but I fixed the nexus mod tools with that)
Rewriting the majority of my ships and devices.
Removing smaller automatic weaponry.
Using normal nexus effects/sounds instead of my custom ones.
Decreasing the amount of weapons on ships.
And likely a few other things I forgot.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #4 on: December 02, 2010, 12:38:07 »
Sent you an email about the issue :)

Offline Lt.Brandon

  • Crewman
  • *
  • Posts: 39
  • Karma: 0
  • FIRE ZE MISSILEZ!
    • View Profile
    • War of The Damned MODDB Page
(No subject)
« Reply #5 on: December 02, 2010, 16:07:11 »
Thanks :) I seem to have found the problem.
I forgot that I had added a pirate race while messing around a while back, and that seems to have been causing a problem for what ever strange reason. Oh well I wasn't using it anyways so now that's cleared up  :thumbsup:

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
Re: Working around the ship limit finally possible?
« Reply #6 on: December 02, 2010, 18:29:10 »
Wow.... Excellent! This is indeed great news! finally we don't have to deal with that stupid limit anymore!

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
Re: Working around the ship limit finally possible?
« Reply #7 on: January 16, 2011, 17:48:52 »
Aww, damnit... should have tested this further. While trying to incorperate some ideas from my warfare mod experiment into the Freespace mod, I also tried adding this "no ship limit"-fix to the script. Turns out it doesn't quite work as it first appeared to: they don't react to any of the basic commands (approach, destroy hull, etc.), only to manual controls - so you have to use the manual weapon, device and movement controls to actually get them to do anything. Of course, this'll get really cumbersome, if you've got lots of ships around... which is the whole point of this fix.

The problem most likely stems from the fact, that ships added to the mission this way don't look like ships to game's scripting engine. E.g. if you spawn hundreds of destroyers using this method and then do a simple Select(1,s.ship) in the console to count all ships in the scene, it'll just return the number of "normal" ships and completely ignore the hundreds of destroyers you just spawned.

From what I can see, the problem seems to be the ship-variable, which is 0 for these "fixed" ships. The SelectShips()-command or the Select(1,s.ship) above check exactly this variable to distinguish between ships and other objects. Additionally many scripts check for the ship-variable to validate parameters or to select a group of ships. These kind of actions would completely ignore everything spawned this way, breaking quite a lot of scripts along the way.

I'm not sure about how to get this to work. Of course, any mission scripts for your particular mod can be altered to work with these "hacked" ships. For example, you could assign a hackedShip-variable to each ship spawned using this method and add additional checks for this variable where appropriate.
You'd also need to redo all the default commands in the command bar, so they'd work with that variable as well.

... the question remains, however, if there is anything really hardcoded dependend on this variable... hardcoded somewhere out of reach, especially. :(