Author Topic: Replacing stock ships with scripts  (Read 901 times)

Offline Lord Tribble

  • Posts: 333
  • Cookies: 2
Replacing stock ships with scripts
« on: May 28, 2013, 10:48:47 AM »
This is probably a face palm worthy simple thing, but I can't for the life of me figure it out.

How do I completely replace the stock ships (Bird of Prey, warbird etc) by editing the scripts rather than replacing the model/icon files?
I've already got them to use the right models and HP by changing the scripts/ships files, but when I try to create a script for them in scripts/custom to change the description and icon, I end up with duplicate entries in ship selection menus. The script does change the icon and description, but I get two buttons for the same ship.

I know it must be possible to do this without duplicating as I've had mods that replaced the stock Fed ships, and been able to later edit those scripts to change the description and icons.

Offline JimmyB76

  • Posts: 6423
  • Cookies: 421
Re: Replacing stock ships with scripts
« Reply #1 on: May 28, 2013, 11:06:14 AM »
did you use BCUT?  did you delete the pyc files?

Offline Lord Tribble

  • Posts: 333
  • Cookies: 2
Re: Replacing stock ships with scripts
« Reply #2 on: May 28, 2013, 11:15:45 AM »
I've tried making the plugin file both by copying and editing one from another bop, and creating an entirely new one in bcut

As far as I could see, there wasn't a pyc file to delete for the stock ones :idk:

Offline JimmyB76

  • Posts: 6423
  • Cookies: 421
Re: Replacing stock ships with scripts
« Reply #3 on: May 28, 2013, 11:27:14 AM »
can you post the code of one of your plugins youre trying to change?
there are 2 different ways to go about this...

Offline Lord Tribble

  • Posts: 333
  • Cookies: 2
Re: Replacing stock ships with scripts
« Reply #4 on: May 28, 2013, 11:47:29 AM »
#####  Created by:
#####  Bridge Commander Universal Tool


import App
import Foundation


abbrev = "BirdOfPrey"
iconName = "ErmeyBOP"
longName = "Bird of Prey"
shipFile = "BirdOfPrey"
species = App.SPECIES_GALAXY
menuGroup = "Klingon Ships"
playerMenuGroup = "Klingon Ships"
Foundation.ShipDef.BirdOfPrey = Foundation.KlingonShipDef(abbrev, species, { 'name': longName, 'iconName': iconName, 'shipFile': shipFile })


Foundation.ShipDef.BirdOfPrey.desc = "test1"


if menuGroup:           Foundation.ShipDef.BirdOfPrey.RegisterQBShipMenu(menuGroup)
if playerMenuGroup:     Foundation.ShipDef.BirdOfPrey.RegisterQBPlayerShipMenu(playerMenuGroup)


if Foundation.shipList._keyList.has_key(longName):
      Foundation.ShipDef.__dict__[longName].friendlyDetails[2] = Foundation.shipList[longName].friendlyDetails[2]
      Foundation.ShipDef.__dict__[longName].enemyDetails[2] = Foundation.shipList[longName].enemyDetails[2]

Offline JimmyB76

  • Posts: 6423
  • Cookies: 421
Re: Replacing stock ships with scripts
« Reply #5 on: May 28, 2013, 12:21:41 PM »
ok first off - the EmeryBOP icon - why didnt you just rename that and then overwrite the stock BOP icon with that one?

for the ship description - you can try this in the plugin (after import Foundation)
Code: [Select]
ship = Foundation.ShipDef.BirdOfPrey"
ship.hasTGLName = 0
ship.hasTGLDesc = 1

the other method would be to edit the ships.TGL (using TGL editor) for the Bird Of Prey entry...

Offline Lord Tribble

  • Posts: 333
  • Cookies: 2
Re: Replacing stock ships with scripts
« Reply #6 on: May 28, 2013, 12:38:34 PM »
ok first off - the EmeryBOP icon - why didnt you just rename that and then overwrite the stock BOP icon with that one?

Trying to see if I could do it without ;)

for the ship description - you can try this in the plugin (after import Foundation)
Code: [Select]
ship = Foundation.ShipDef.BirdOfPrey"
ship.hasTGLName = 0
ship.hasTGLDesc = 1

the other method would be to edit the ships.TGL (using TGL editor) for the Bird Of Prey entry...


Tried adding that, no difference :(.

I don't understand how some mods have done what I'm trying to do. They don't seem to have touched the TGL

Offline ACES_HIGH

  • BCC Roleplay Game Narrator
  • Moderator
  • Posts: 1678
  • Cookies: 54
  • while(!(succeed=try()));
    • BCC Roleplay Games
Re: Replacing stock ships with scripts
« Reply #7 on: May 28, 2013, 02:28:06 PM »
I've tried making the plugin file both by copying and editing one from another bop, and creating an entirely new one in bcut

As far as I could see, there wasn't a pyc file to delete for the stock ones :idk:

if it's stock, the game should only have a .pyc for it.  The stock game doesn't have any uncompiled .py files.  In order to get those, you need to download the SDK.  And the game should automatically compile any .py files it can find too.

Offline JimmyB76

  • Posts: 6423
  • Cookies: 421
Re: Replacing stock ships with scripts
« Reply #8 on: May 28, 2013, 02:32:38 PM »
rename the icon to have the same name as the stock icon and overwrite it...
also try manually editing the Ships.TGL itself...

if it's stock, the game should only have a .pyc for it.  The stock game doesn't have any uncompiled .py files.  In order to get those, you need to download the SDK.  And the game should automatically compile any .py files it can find too.
the stock game doesnt come with any plugins...  all the stock ship plugins are in the StaticDefs script...
also, the game wont compile any py files on it's own...

Offline Lord Tribble

  • Posts: 333
  • Cookies: 2
Re: Replacing stock ships with scripts
« Reply #9 on: May 28, 2013, 03:16:48 PM »
I've just tried what I was doing with the warbird, and that worked fine.

The bop however still doesn't wan't to play ball, I can change the icon and description with the scripts/custom plugin, but I also get two buttons for it   :idk:

Offline Lord Tribble

  • Posts: 333
  • Cookies: 2
Re: Replacing stock ships with scripts
« Reply #10 on: May 28, 2013, 05:22:25 PM »
Found where I was going wrong; in the staticdefs file, the bird of prey is given 'BOP' as a name. I entered that into the longname field and it has successfully overidden the other button.
It showed up as BOP in the friendly and enemy lists though, so I added the tgl name line to call them 'Bird of Prey' again. They're not given numbers but the stock didn't get them either so I'm not gonna try to bodge that.

This is the plugin script I ended up with;

-------------------

#####  Created by:
#####  Bridge Commander Universal Tool


import App
import Foundation



abbrev = "BirdOfPrey"
iconName = "ErmeyBOP"
longName = "BOP"
shipFile = "BirdOfPrey"
species = App.SPECIES_BIRD_OF_PREY
menuGroup = "Klingon Ships"
playerMenuGroup = "Klingon Ships"
Foundation.ShipDef.BirdOfPrey = Foundation.KlingonShipDef(abbrev, species, { 'name': longName, 'iconName': iconName, 'shipFile': shipFile })


Foundation.ShipDef.BirdOfPrey.hasTGLName = 1
#Foundation.ShipDef.BirdOfPrey.hasTGLDesc = 1

#Foundation.ShipDef.BirdOfPrey.name = "Bird of Prey"
Foundation.ShipDef.BirdOfPrey.desc = "No information available."



if menuGroup:           Foundation.ShipDef.BirdOfPrey.RegisterQBShipMenu(menuGroup)
if playerMenuGroup:     Foundation.ShipDef.BirdOfPrey.RegisterQBPlayerShipMenu(playerMenuGroup)


if Foundation.shipList._keyList.has_key(longName):
      Foundation.ShipDef.__dict__[longName].friendlyDetails[2] = Foundation.shipList[longName].friendlyDetails[2]
      Foundation.ShipDef.__dict__[longName].enemyDetails[2] = Foundation.shipList[longName].enemyDetails[2]

---------------------


I found a way of doing it by editing the staticdefs file as well, but I didn't want to risk messing up any foundation scripts. Not really sure what the tgls are so I didn't want to risk breaking those either!


Thanks Guys!