Author Topic: Related to Core Eject (my own additions)  (Read 678 times)

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Related to Core Eject (my own additions)
« on: July 09, 2019, 01:57:57 AM »
Hi guys (and gals I guess if you exist on the internet :P )

So I am working on some code that will check if the power system is at or below its disabled percentage, and if true, a chance is calculated against a timer of 1 second that then loops back to itself, effectively creating a sort of real time monitoring of the warp core's health percentage, and then  applies a (very small for now) chance for warp core integrity to fail causing destruction of the ship. I am quite close to achieving this one, most of the code now works (tested it with SFX clips haha). Just need to figure out how to keep the loop looping after it detects "fused antimatter injectors" and proceeds to destroy itself (probably something with ShipExploding; Krrks will hate me now because he already helped me fix that problem once before :P )

If anyone feels like playing around with it: (already changed code as of this posting)
Spoiler: show
Code: [Select]
def TestDef(pObject, pEvent):
# pSound = App.TGSound_Create("sfx/Bridge/Crew/Engineering/ge015.mp3", "EPE", 0)
# pSound.SetSFX(0)
# pSound.SetInterface(1)
# App.g_kSoundManager.PlaySound("EPE")

pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pMission = pEpisode.GetCurrentMission()
pPlayer = MissionLib.GetPlayer()
pPower = pPlayer.GetPowerSubsystem()
pShields = pPlayer.GetShields()
pSet = pPlayer.GetContainingSet()
pBridge = App.g_kSetManager.GetSet('bridge')
Hull = pPlayer.GetHull()
WarpCore = pPlayer.GetPowerSubsystem()
Chance = App.g_kSystemWrapper.GetRandomNumber(99)
PowerCondition1 = pPower.GetCondition()
PowerCondition = pPower.GetConditionPercentage()
PowerDisability = pPower.GetDisabledPercentage()

if not (WarpCore):
pStatusTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".TestDef", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
return
if (WarpCore):
if not (PowerCondition <= PowerDisability):
# pSound = App.TGSound_Create("sfx/Bridge/Crew/Engineering/PowerDisabled.mp3", "EPE", 0)
# pSound.SetSFX(0)
# pSound.SetInterface(1)
# App.g_kSoundManager.PlaySound("EPE")
pStatusTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".TestDef", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
return
if (PowerCondition <= PowerDisability):
# pStatusTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".TestDef", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
if (Chance >= 5):
# pStatusTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".TestDef", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
return
if (Chance < 5):
pSound = App.TGSound_Create("sfx/Bridge/Crew/Engineering/ge015.mp3", "EPE1", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("EPE1")
pPlayer.DestroySystem(Hull)
pPlayer.DestroySystem(WarpCore)
pStatusTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".TestDef", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
return
pStatusTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".TestDef", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
pStatusTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".TestDef", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
pStatusTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".TestDef", App.g_kUtopiaModule.GetGameTime() + 3, 0, 0)


And about the core eject, I have yet to write up any code for this, but I am planning an attempt to grab the current warp core health percentage (example: 75%) and apply that to the core after it has been "ejected" (but in reality its just a new ship/hardpoint being loaded into the game). After all, shouldn't a damaged warp core remain damaged even after it is disconnected from the ship?

Offline FekLeyr Targ

  • DS9FX Team
  • Posts: 490
  • Cookies: 537
Re: Related to Core Eject (my own additions)
« Reply #1 on: July 09, 2019, 05:31:07 AM »
Sounds great.
I suggested something like that many moons ago, so I'm happy that this is becoming a thing now. :)

Back when I suggested it, there were concerns about possible conflicts with the construction mod, which enables shipyards to build ships and construction vessels to build stations.
Ships and stations under construction start with about 1% health for each hardpoint, including the main reactor (warp core etc). The core breach script could cause ships and stations under construction to explode instantly.

So this begs the question: How could that conflict be solved?
TaH pagh, Tah be.

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Related to Core Eject (my own additions)
« Reply #2 on: July 09, 2019, 11:12:24 AM »
Great info you posted there sir, thank you. I hadn't really thought that far ahead, more of a bridge to cross when we get there. However, a simple fix (at least in my opinion) would be that any new ship/station under construction would receive a core with a 100% health, since this mod would only really affect the power core system. All other subsystems would need to be "healed" normally. I would argue that no engineer is going to build, piece by piece, a warp core from inside the ship. I would argue that the core comes as a complete unit, and only the antimatter injectors need to be connected and flowing fuel to power the core 100%. I was unaware you had proposed this idea. Great minds :)

Alternatively, another way to fix that would be to (in the construct scripting) turn off the warp cores while they "heal", and then insert checks in my code to "skip" past any warp cores that have the condition "if not pPower.IsOn(): return". Meaning that if the core is not on, return to end.

However, thinking even more I do believe my code only affects pPlayer and not AI or NPC ships (another bridge to cross if need be)

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2186
  • Cookies: 1706
  • Life is life
Re: Related to Core Eject (my own additions)
« Reply #3 on: July 09, 2019, 09:19:10 PM »
Quote
Just need to figure out how to keep the loop looping after it detects "fused antimatter injectors" and proceeds to destroy itself (probably something with ShipExploding; Krrks will hate me now because he already helped me fix that problem once before :P )

Can you elaborate the problem you're facing in more detail, maybe I can provide some advice.

Also, the code snipet you posted will only work for the player vessel. I recommend that you switch to a single timer and use dictionary to store values you need. Much easier to track everything if one global timer is running in background. If you need an example, you can mimic the following approach https://github.com/bcssov/FixTorps/blob/master/Custom/Autoload/FixTorps.py. If something is unclear feel free to ask.
Acta, non verba.
aka USS Sovereign

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Related to Core Eject (my own additions)
« Reply #4 on: July 09, 2019, 10:59:52 PM »
Sov, you give me more credit than I deserve. Alot of what I have been doing has been hit-or-miss for me. I understand scripts about as well as a pig understands flying. Albeit I have been getting a bit bolder with my projects, each one seems to increase in difficulty. Or perhaps thats just my lack of knowledge. So about this perpetual core integrity check/loop...

Since I dev using multiplayer exclusively (quickbattle is my secondary? priority if that makes any sense) I am finding that some things require ShipExploding and NewPlayerShip broadcast handlers. However, I am not quite sure how to use those functions either, such as placement within the clauses and whatnot... I have a timer on an init def that begins the looping feature to check warp core status every x amount of seconds (I set it to 1 for now for easy testing). This init def also has buttons. There seems to be no issue here with the buttons or initial call to loop (via timer). The issue begins when player dies and selects a new ship. For some reason going back to ship select screen breaks the loop and the init def is not reloaded, thus the loop feature does not persist as desired. I have had success setting the timer higher and quickly selecting a ship to respawn, but anyone can just wait however much longer than that timer causing them to be free of the core integrity check/loop. I have some updated code also which is linked through several defs so it would be silly of me to post that code. It's a really really big file. I hope all that helps.

Quote
length: 155746     lines: 3088
<- alot of that size is false because I have alot of crap to remove before its easily navigable

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2186
  • Cookies: 1706
  • Life is life
Re: Related to Core Eject (my own additions)
« Reply #5 on: July 10, 2019, 11:51:53 AM »
Can you post the whole code regardless?
Acta, non verba.
aka USS Sovereign

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Related to Core Eject (my own additions)
« Reply #6 on: July 18, 2019, 02:31:17 PM »
I can send it to you in PM, but I have been changing it up just about every day and feel like I have been making some progress. I am probably doing it wrong, and I look forward to being chewed out by a script god; just not before I get it more than 3/4 of the way working. I know, it has to be the NewPlayerShip def, I am certain I don't have the handlers placed correctly; otherwise it should be working

current file size
Quote
length: 159997     lines: 3181

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Related to Core Eject (my own additions)
« Reply #7 on: November 27, 2019, 07:14:20 PM »
I have made progress with this mod, and am now happy with the level of effectiveness it provides. Still not perfect, but definitely making some good progress. Also, the filesize is now:

Quote
length: 168555    lines: 3321