Yes, this again. I'm sure this topic has been talked about over and over.. but...
I was using this function recently, but realized that it has some funny side effects. For one, the max impulse of the ships are affected, which tells me at least some of the hardpoint is being rescaled; my guess is pShip.GetImpulseEngineSubsystem().GetMaxSpeed() as I was able to multiply by a weird value to restore this to very close to original max impulse velocities, I do believe the angular velocity/accel and maxaccel are also rescaled. The math does not seem to add up. Second, and most obvious, the beams emit from either far off the ship for scaled down models or (I am assuming here), too far into the model on a scaled up ship. I have tried to fix the latter with no luck. I looked in App and MissionLib for clues. I have yet still a few things to try, but I am coming here in hopes some of you have more technical input than I have seen in searches around here. I present you with some code:
from bcdebug import debug
################################################################################################################
#
# Tethys notes-
#
# One thing I have noticed about Rescale mod is that it not only rescales the ship model, but also
# rescales some subsystem properties (example: rescale Impulse System max speed value), yet it fails to
# rescale other hardpoint attributes (phaser beam origin point). I have formulated a fix which I believe
# can be applied to other rescaled subsystem properties. The math behind the fix is not right (it seems
# to multiply itself 3-fold), its more or less a best guesstimate. Additionally, some scripting is
# incomplete or incorrect, but I believe with some persistence and clever coding it can be possible to
# also rescale the child subsystems origin points. WIP
#
# I would also like to use a dynamic ShipName (sCurName)? rather than a static one, if I can ever figure
# that out...
#
################################################################################################################
import App
import MissionLib
MODINFO = { "needBridge": 0 }
# use the ShipName of the Hardpoint file as key here
g_dShipScales = {
"Akira": 0.4,
# "USSCentury": 0.4,
}
def ObjectCreatedHandler(pObject, pEvent):
debug(__name__ + ", ObjectCreatedHandler")
pShip = App.ShipClass_Cast(pEvent.GetDestination())
if pShip:
rescale(pShip)
pObject.CallNextHandler(pEvent)
def rescale(pShip):
if not pShip:
return
if not pShip.GetShipProperty():
return
sShipProbName = pShip.GetShipProperty().GetShipName()
for sCurName in g_dShipScales.keys():
if sCurName == sShipProbName:
pShip.SetScale(g_dShipScales[sCurName])
# Okay, so we need to scale up some things that got reduced and scale down some things that were missed...
ImpEng = pShip.GetImpulseEngineSubsystem()
MaxSpeed = ImpEng.GetMaxSpeed() #2696 USSCentury 6740
ImpEng.GetProperty().SetMaxSpeed(MaxSpeed*1.35725)
PhaSys = pShip.GetPhaserSystem()
PhaRadius = PhaSys.GetRadius()
PhaSys.GetProperty().SetRadius(PhaRadius/1.35725)
# Something here disappears alot of buttons, probably a hang up due to invalid values/code or incorrectly selected XYZ
# iWeapons = PhaSys.GetChildSubsystems()
# iWeapons = pShip.GetPhaserSystem().GetChildSubsystems()
# position = iWeapons.GetPosition()
# position2d = iWeapons.GetPosition2D()
# iWeapons.GetProperty().SetPosition(position/1.35725)
# iWeapons.GetProperty().SetPosition2D(position2d/1.35725)
# The following is not really intended to work, the structure was broken intentionally (more for info than use)
# if PhaSys:
# iWeapons = PhaSys.GetChildSubsystems()
# for iWeap in range(iWeapons):
# qWeaponChild = PhaSys.GetChildSubsystem(iWeapons)
# if str(qWeaponChild) != str(PhaSys):
# position = iWeapons.GetPosition()
# position2d = iWeapons.GetPosition2D()
# iWeapons.SetPosition(position/1.35725)
# iWeapons.SetPosition2D(position2d/1.35725)
# pSequence = App.TGSequence_Create()
# pSet = pPlayer.GetContainingSet()
# pEmitFrom = App.TGModelUtils_CastNodeToAVObject(pPlayer.GetNode())
# pPlayerNode = pPlayer.GetNode()
# pAttachTo = pSet.GetEffectRoot()
# vEmitPos = qWeaponChild.GetPosition()"""
def init():
debug(__name__ + ", init")
App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_OBJECT_CREATED, MissionLib.GetMission(), __name__ + ".ObjectCreatedHandler")
App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_OBJECT_CREATED_NOTIFY, MissionLib.GetMission(), __name__ + ".ObjectCreatedHandler")
# Adjust existing ships
lSets = App.g_kSetManager.GetAllSets()
for pSet in lSets:
for pShip in pSet.GetClassObjectList(App.CT_SHIP):
rescale(pShip)