bckobayashimaru.de

Bridge Commander Kobayashi Maru Project
It is currently Wed May 22, 2019 7:40 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Modified PulseTech
PostPosted: Sun May 18, 2014 10:56 pm 
Offline
Cadet 2nd Year
Cadet 2nd Year

Joined: Fri Jan 03, 2014 10:33 pm
Posts: 30
Location: Eisenach, Germany
I've modified the PulseTech-Script from QBautostart. The effect of the changes that the projectile script will not be loaded from the ship script but from the ship definition.

Code:
import App
import MissionLib
import Foundation
import string

MODINFO = { "Author": "ed",
            "Download": "",
            "Version": "2.0",
            "License": "",
            "Description": "Allows in-game switching of disruptor projectiles"
            }


def CyclePulseType(pObject, pEvent):
   global CurIndex
   CurIndex=CurIndex+1
   SetPulseScript(CurIndex)
   return

def SetPulseScript(Index):
   global PulseButton
   global CurIndex
   CurIndex=Index
   bError = 0
   try:
      pShip=MissionLib.GetPlayer()
      pPulseSys=pShip.GetPulseWeaponSystem()
      pPulseProperty=pPulseSys.GetProperty()
      pShipModule=__import__(pShip.GetScript())      
      pType = string.split(pShip.GetScript(), '.')[-1]      
   except:
      CurIndex=1
      bError = 1
      #print 'No ship or no pulse weapon system'   
   try:   
      if (Foundation.shipList[pType] and hasattr(Foundation.shipList[pType], "PulseTech")):
         pTech = Foundation.shipList[pType].PulseTech
         PulseType = pTech[CurIndex]
         #print PulseType
   except:
      CurIndex=1
      bError = 1      
      #print 'No foundation entry or no PulseTech attribut'   
   try:   
      pProjectile=__import__(PulseType)
      BtnName=str(CurIndex)+":"+pProjectile.GetName()
      PulseButton.SetName(App.TGString(BtnName))
      if (pPulseSys):
         for iPulseNum in range(pPulseSys.GetNumChildSubsystems()):
            pSubsystem = pPulseSys.GetChildSubsystem(iPulseNum)
            pWeapon = App.PulseWeapon_Cast(pSubsystem)
            pPulseCannon = App.PulseWeaponProperty_Cast(pWeapon.GetProperty())
            pPulseCannon.SetModuleName(PulseType)
   except:
      CurIndex=0
      bError = 1
   
   if bError:
      try:
         PulseButton.SetName(App.TGString("No Pulse Routine"))
      except:
         pass
      return
   return PulseType


# The Button
def init():
   global PulseButton
   global CurIndex
   import Libs.LibEngineering
   PulseButton=Libs.LibEngineering.CreateMenuButton("No Pulse Routine", "Tactical", __name__ + ".CyclePulseType")
   SetPulseScript(1)
   return

def Restart():
   global CurIndex
   global PulseButton
   SetPulseScript(1)
   return


Example Code for BirdofPrey:

Code:
Foundation.ShipDef.CloakFireBirdOfPrey.PulseTech = { 1: 'Tactical.Projectiles.PulseDisruptor', 2: 'Tactical.Projectiles.Disruptor', 3: 'Tactical.Projectiles.Disruptor2', 4: 'Tactical.Projectiles.MPneghvarpulse' }


The reason and the objective of this change is that you can use this mod for all ships without changing the ship scripts. Changing the ship scripts finally has indeed impact on the multiplayer. This is avoided by this.


Attachments:
PulseTech.py [1.96 KiB]
Downloaded 857 times
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB® Forum Software © phpBB Group