Author Topic: TMP Warmup Script Problem  (Read 2254 times)

Offline X_TheUnknown_X

  • Posts: 325
  • Cookies: 328
  • (Semi) Retired
TMP Warmup Script Problem
« on: October 26, 2009, 07:01:34 AM »
I've been trying to get the TMP Engine warmup script to work on my Akula class, but even though I've added the appropriate lines of script in the plugin file, I still can't get the ship to swap the textures ingame.

I've installed Adonis' Akyazi class and the nacelles change colour on that ship, but just not on my Akula. I've checked to make sure all the Filenames and directories are correct, and there are no script errors showing up on the console; I simply can't find a reason why it won't work. Which is why I've come here. Can anyone tell me what I'm doing wrong here? I'll attach my ship plugin file if it will help.

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: TMP Warmup Script Problem
« Reply #1 on: October 26, 2009, 01:37:32 PM »
From a first look at it I'm unable to find an Error too. But I never used the Warmup before...
To through out one of my stupid Questions again: The Texture the Ship uses normaly is the right one, you want to replace, rigth? (I had once a similar SDT Error because i used the wrong Texture on the ship)
Maybe your other ship files would also help.

Offline X_TheUnknown_X

  • Posts: 325
  • Cookies: 328
  • (Semi) Retired
Re: TMP Warmup Script Problem
« Reply #2 on: October 26, 2009, 02:52:32 PM »
Yep, just checked. The Plas_glow.tga file is the one the ship normally uses for Non-Warp, and the Plas1_glow.tga for In-Warp. It's just that Plas1 won't show up.

Offline baz1701

  • Posts: 3392
  • Cookies: 1434
Re: TMP Warmup Script Problem
« Reply #3 on: October 26, 2009, 04:48:44 PM »
what about the main file in the scripts/tech folder?
Whatever knocks us back, can only make us stronger.

Offline X_TheUnknown_X

  • Posts: 325
  • Cookies: 328
  • (Semi) Retired
Re: TMP Warmup Script Problem
« Reply #4 on: October 26, 2009, 05:27:23 PM »
The AdonisTMPWarp.py file is in the proper folder: scripts/Custom/Techs along with the other FTech stuff like 'Phased Cloak' and 'SubModels'. Besides, Adonis' Akyazi still works - and the script is copied from there. I might try removing the Akula from my install and write my plugin files manually. I've also tried using the second example Adonis gives in the file: using "startTrack" and "stopTrack", but I can't be sure I'm using it properly. A longer tutorial of it might help

Offline Adonis

  • Ze Meister xP
  • Posts: 670
  • Cookies: 84
  • Da Death Squad ???
    • Star Trek Excalibur
Re: TMP Warmup Script Problem
« Reply #5 on: October 27, 2009, 01:51:09 AM »
The AdonisTMPWarp.py file is in the proper folder: scripts/Custom/Techs along with the other FTech stuff like 'Phased Cloak' and 'SubModels'. Besides, Adonis' Akyazi still works - and the script is copied from there. I might try removing the Akula from my install and write my plugin files manually. I've also tried using the second example Adonis gives in the file: using "startTrack" and "stopTrack", but I can't be sure I'm using it properly. A longer tutorial of it might help

Dude, do you have your own textures for the swap? Because you have to have them. Plas_glow.tga and Plas1_glow.tga are the texture names I used for the Akyazis, Novi Sad, Ashton and so forth, the Mesopotamia (which I should get off my butt finally and release) works in a different manner (has PlasI_glow, PlasO_glow, PlasI1_glow, PlasO1_glow - i.e. the inner and outer pair use one texture). I'll include the Meso's code for the warmup with a bit of explanation. The plasma textures I use are 512x64 textures (since swap textures should be small, minus IDMaps), the ships that use her have to be set up correctly too.

Code: [Select]
Foundation.ShipDef.AdMesoLagash.dTechs = {  <<-- the abbrev cmd's value, you got this right
# Here comes the AdonisTMPWarmUp script config
# The sequence describes the warm up, and it's reversed (timed correctly) on cool off
# The numbers are moments in time
# 2 requirements, the first moment is the normal texture, and the last moment
# On the other hand, you can also use startTrack and stopTrack, with the same config, but you can time it differently, and use different textures (if you want)
"AdonisTMPWarpStartUp": {
"track": {
"PlasI_glow": { <<-----the inner plasma pairs original texture name
0.0: "data/Models/Ships/AdTMP/MesopotamiaLate/PlasI_glow.tga",
1.0: "data/Models/Ships/AdTMP/MesopotamiaLate/PlasI1_glow.tga",
},
"PlasO_glow": {  <<----the outer plasma pairs original texture name
0.0: "data/Models/Ships/AdTMP/MesopotamiaLate/PlasO_glow.tga",
1.0: "data/Models/Ships/AdTMP/MesopotamiaLate/PlasO1_glow.tga",
}
}
}
}

This is the Lost Era version which swaps both outer and inner pairs on and off. So without Leo's and my own explanations it should look like this: (note the nr. of { and } for future reference)

Code: [Select]
Foundation.ShipDef.AdMesoLagash.dTechs = {
"AdonisTMPWarpStartUp": {
"track": {
"PlasI_glow": {
0.0: "data/Models/Ships/AdTMP/MesopotamiaLate/PlasI_glow.tga",
1.0: "data/Models/Ships/AdTMP/MesopotamiaLate/PlasI1_glow.tga",
},
"PlasO_glow": {
0.0: "data/Models/Ships/AdTMP/MesopotamiaLate/PlasO_glow.tga",
1.0: "data/Models/Ships/AdTMP/MesopotamiaLate/PlasO1_glow.tga",
}
}
}
}

Also, you might have noticed that I don't use the high folder for the plasma textures, this is just how I prefer it. Maybe even this script of Leo's has a nice trick to it as SDT does that it automatically "assumes" high, med and low folders. Anyone who took a close look at my own ships might have noticed that I don't include the high folder in my SDT entries.

If this explanation doesn't help, I'll have to take a look at the whole ship itself.
Easy is the path to wisdom for those not blinded by themselves.


Offline baz1701

  • Posts: 3392
  • Cookies: 1434
Re: TMP Warmup Script Problem
« Reply #6 on: October 27, 2009, 05:25:27 AM »
Should not the main script be edited to each ship. for example the base script
Code: [Select]
Foundation.ShipDef.Ship name here.dTechs
So therefore should you script read

Code: [Select]
Foundation.ShipDef.TUAkula.dTechs
Here is the script I used for the JJrefit, edited to suit your ship

Code: [Select]
#############################################
##    ##
## Adonis TMP Warp Startup "Technology"    ##
## By MLeo Daalder, commissioned by Adonis ##
##    ##
#############################################

"""
Adonis TMP Warp Startup script

Usage (mostly by example this time, sorry, had to cut it a bit due to school pressure):
Foundation.ShipDef.AdLuxor.dTechs = {
# Here comes the AdonisTMPWarmUp script config
# The sequence describes the warm up, and it's reversed (timed correctly) on cool off
# The numbers are moments in time
# 2 requirements, the first moment is the normal texture, and the last moment
# On the other hand, you can also use startTrack and stopTrack, with the same config, but you can time it differently, and use different textures (if you want)
"AdonisTMPWarpStartUp": {
"track": {
"Plas_glow": {
0.0: "data/Models/Ships/TUAkula/High/Plas_glow.tga",
1.0: "data/Models/Ships/TUAkula/High/Plas1_glow.tga",
}
}
}
}
"""

import App
import Foundation
import FoundationTech
import string


class ListCompare:
def __init__(self, list):
self.list = list

def __cmp__(self, other):# Not entirely according to convention, but it does the trick
return not other in self.list

##################################################
## ##
## Right, this acts like a module replacement, ##
## since global variables need to be "imported" ##
## using the global keyword while globals from ##
## a module don't. Using static variables from ##
## a class give the same effect while loosing ##
## the dependance of the module. ##
## ##
##################################################
class types:
DictionaryType = type({})
ListType = type([])
TupleType= type(())
StringType = type("")
ArrayType    = ListCompare([ListType, TupleType])
SequenceType = ListCompare([StringType, ArrayType])
ContainerType= ListCompare([DictionaryType, SequenceType])

types.InstanceType = type(types())

class TUAkulaTMPWarpStartUpDef(FoundationTech.TechDef):
def AttachShip(self, pShip, pInstance):
#pShip = App.ShipClass_Cast(App.TGObject_GetTGObjectPtr(pInstance.pShipID))
if pShip and getattr(pInstance, self.name, None):
if not hasattr(pInstance, "TextureRegistration"):
pInstance.TextureRegistration = {}
if hasattr(pInstance, "NormalTextures"):
PreProcessTextureRegistration(pInstance)
if not getattr(pInstance, "bAddedTUAkulaTMPWarpHandlers", 0):
pShip.AddPythonFuncHandlerForInstance(App.ET_START_WARP, __name__ + ".StartingWarp")
pShip.AddPythonFuncHandlerForInstance(App.ET_START_WARP_NOTIFY, __name__ + ".StartingWarp")
pShip.AddPythonFuncHandlerForInstance(App.ET_EXITED_SET, __name__ + ".ExitSet")
pInstance.bAddedTUAkulaTMPWarpHandlers = 1

def DetachShip(self, pShipID, pInstance):
pShip = App.ShipClass_Cast(App.TGObject_GetTGObjectPtr(pInstance.pShipID))
if pShip and getattr(pInstance, "bAddedTUAkulaTMPWarpHandlers", 0):
pShip.RemoveHandlerForInstance(App.ET_START_WARP, __name__ + ".StartingWarp")
pShip.RemoveHandlerForInstance(App.ET_START_WARP_NOTIFY, __name__ + ".StartingWarp")
pShip.RemoveHandlerForInstance(App.ET_EXITED_SET, __name__ + ".ExitSet")
pInstance.bAddedTUAkulaTMPWarpHandlers = 0


oTUAkulaTMPWarpStartUp = TUAkulaTMPWarpStartUpDef("TUAkulaTMPWarpStartUp")

def StartingWarp(pObject, pEvent):
pObject.CallNextHandler(pEvent)

pShip = App.ShipClass_Cast(pObject)
pInstance = FoundationTech.dShips[pShip.GetName()]
# Check to see if this is a valid ship
if not getattr(pInstance, "bAddedTUAkulaTMPWarpHandlers", 0):
return # Ok, not a valid ship, bye bye!
dConfig = getattr(pInstance, "TUAkulaTMPWarpStartUp")
if not dConfig:
return
if dConfig.has_key("startTrack"):
dConfig = dConfig["startTrack"]
else:
dConfig = dConfig.get("track", {})
RollTextures(pInstance, pShip, dConfig)

def ExitSet(pObject, pEvent):
pObject.CallNextHandler(pEvent)

pShip = App.ShipClass_Cast(pEvent.GetDestination())
        sSetName = pEvent.GetCString()
# if the system we come from is the warp system, then we exitwarp, right?
        if sSetName != "warp":
#print "I thought we were exiting warp?", sSetName, pShip.GetName()
return
pInstance = FoundationTech.dShips.get(pShip.GetName())
if not pInstance:
return
# Check to see if this is a valid ship
if not getattr(pInstance, "bAddedTUAkulaTMPWarpHandlers", 0):
return # Ok, not a valid ship, bye bye!
dConfig = getattr(pInstance, "TUAkulaTMPWarpStartUp")
if not dConfig:
return
bReverse = 0
if dConfig.has_key("stopTrack"):
dConfig = dConfig["stopTrack"]
else:
dConfig = dConfig.get("track", {})
bReverse = 1
RollTextures(pInstance, pShip, dConfig, bReverse)

def RollTextures(pInstance, pShip, dTextures, bReverse=0):
for name, textures in dTextures.items():
lTextures = textures.items()
lTextures.sort()
if bReverse:
# The first and the last textures are at the same moments!
lTimes = textures.keys()
lTimes.sort()
fFirst = lTimes[0]
fLast  = lTimes[-1]
lTimes.reverse()
lNew = [fFirst]
for i in range(1, len(lTimes)):
time = lTimes[i]
prev = lTimes[i-1]
lNew.append((prev-time) + lNew[i-1])
# Reintegrate changes
lNewTextures = []
for i in range(len(lTextures)):
lNewTextures.append((lNew[i], lTextures[i][1]))
lTextures = lNewTextures
pTextureMap = pInstance.TextureRegistration.get(name, None)
if not pTextureMap:
pTextureMap = TextureMap(name)
pInstance.TextureRegistration[name] = pTextureMap
pTextureMap.SwitchMap(pShip, lTextures)

class TextureMap:
def __init__(self, textureName, currentMap=None):
self.textureName = textureName
if not currentMap: currentMap = textureName[:]
self.currentMap = currentMap[:]
self.pSequence = None
self.bInSequence = 0

def SwitchMap(self, pShip, sNew):
self.StopAnimation()
if type(sNew) == types.StringType:
# Wee... Simple texture replacement
self.InternalSwitchMap(pShip, self.currentMap, sNew)
else:
# Animation, we assume for easyness that this is a "flat" dict type (so ((key, value), (key....
# And that we will only play it once
self.pSequence = App.TGSequence_Create()
fTiming = 0.0
for index, texture in sNew:
self.pSequence.AppendAction(ImmersionMethodScriptAction_Create(self, "InternalSwitchMap", pShip, texture), index-fTiming)
fTiming = index
self.pSequence.AppendAction(ImmersionMethodScriptAction_Create(self, "FinalSequenceAction"))
self.pSequence.Play()
def StopAnimation(self):
if self.bInSequence:
self.bInSequence = 0
if self.pSequence and self.pSequence.IsPlaying():
self.pSequence.Abort()
self.pSequence = None
return 1
return 0
def InternalSwitchMap(self, pShip, sNew):
if self.currentMap == sNew:
return
pShip.ReplaceTexture(sNew, self.currentMap)
pShip.RefreshReplacedTextures()
self.currentMap = DistillNewMapName(sNew)
def FinalSequenceAction(self):
self.bInSequence = 0
self.pSequence = None

def DistillNewMapName(sPath):
return string.split(string.split(sPath, "\\")[-1], "/")[-1][:-4]

def PreProcessTextureRegistration(pInstance):
dTextureRegistration = pInstance.NormalTextures
if not pInstance.pShipID:
return
pShip = App.ShipClass_GetObjectByID(App.SetClass_GetNull(), self.pShipID)
if not pShip:
return
if not hasattr(pInstance, "TextureRegistration"):
pInstance.TextureRegistration = {}
for texture, path in dTextureRegistration.items():
if type(info) != types.InstanceType:
pTextureMap = pInstance.TextureRegistration.get(texture, None)
if not pTextureMap:
pTextureMap = TextureMap(texture)
pInstance.TextureRegistration[texture] = pTextureMap

pTextureMap.SwitchMap(pShip, path)
pTextureMap.SwitchMap(pShip, path)# Extra in case a modder meant "currently swapped texture" (for example, with SDT)
else:
continue# Already a proper texture registration, atleast, we hope it sounds, looks and smells like a duck, eh, texture registration
return

# The next 2 functions are from Immersion, with thanks from LJ.
# They are used to call methods on objects from TGSequences.
# Slightly modified to recieve variable number of arguments by MLeo
#
# Currently taken from BPCore -MLeo

def ImmersionMethodScriptAction_Create(oObject, sMethod, *args):
return apply(App.TGScriptAction_Create, (__name__, "RedirectClassAction", oObject, sMethod,) + args)

def RedirectClassAction(pAction, oObject, sMethod, *args):
if oObject:
pyAttr = getattr(oObject, sMethod)
if pyAttr:
apply(pyAttr, args)
return 0



All I have done is replaced AdLuxor with TUAkula
Whatever knocks us back, can only make us stronger.

Offline Adonis

  • Ze Meister xP
  • Posts: 670
  • Cookies: 84
  • Da Death Squad ???
    • Star Trek Excalibur
Re: TMP Warmup Script Problem
« Reply #7 on: October 27, 2009, 05:52:07 AM »
Baz, you forgot to swap the first AdLuxor entry  :P
Easy is the path to wisdom for those not blinded by themselves.


Offline baz1701

  • Posts: 3392
  • Cookies: 1434
Re: TMP Warmup Script Problem
« Reply #8 on: October 27, 2009, 06:35:15 AM »
noone is perfect :P. I changed it back from my script. but hopefully that may help X_TheUnknown_X
Whatever knocks us back, can only make us stronger.

Offline X_TheUnknown_X

  • Posts: 325
  • Cookies: 328
  • (Semi) Retired
Re: TMP Warmup Script Problem
« Reply #9 on: October 28, 2009, 09:53:08 AM »
I got it working  :funny ! Maybe a little late but it's working. And the reason was just so simple: I had spent hours looking at the model in NifSkope, trying to find out why it wouldn't work - and then I saw: in every case, NifSkope consistently removed the uppercase letters from the texture's name and directory. I went into the plugin script and changed the letters to lowercase and suddenly the nacelle grilles began to light up!

There is only one remaining issue, and it occurs on the Akyazi and Baz's JJPrise as well; after warping, the nacelle grilles don't shut down again, but remain glowing  :wtf . I think it's becuase the line: pTextureMap.SwitchMap(pShip, path) in def PreProcessTextureRegistration is repeated twice? It may also be the way Galaxy Charts alters the warp sequence.

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: TMP Warmup Script Problem
« Reply #10 on: October 28, 2009, 10:44:02 AM »
In this 2 year old thread Mleo and Frontier said the were working on a fix. I don't know what became of it.
http://bc-central.net/forums/index.php/topic,2206.0.html