Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE TranscendenceExtension
- [
- <!ENTITY unidExtension "0xEE000000">
- <!ENTITY itEMC "0xEE004000">
- <!ENTITY stEMCDataStore "0xEE004001">
- <!ENTITY dsEMC "0xEE006000">
- <!ENTITY dsEMCMatter "0xEE006001">
- ]>
- <TranscendenceExtension
- name = "Energy-Matter converter"
- credits = "EditorRUS"
- version = "1.0"
- UNID = "&unidExtension;"
- >
- <Globals>
- (block Nil
- (setq makePowerSink (lambda (euse target)
- (block (powersink)
- (if (eq (isError (itmCreate (typDynamicUNID (cat euse target)) 1)) True)
- (block Nil
- (typCreate (typDynamicUNID (cat euse target)) (subst (typGetStaticData &itEMC; "EnergyLoad")
- {
- target:
- (switch
- (eq target 1)
- "It's collecting power."
- (eq target 2)
- "It's taking power for EMC shields."
- )
- puse: euse
- }
- )
- )
- )
- )
- (setq powersink (itmCreate (typDynamicUNID (cat euse target)) 1))
- (dbgOutput "Success 1")
- powersink
- )
- )
- )
- (setq intCalculateMatterHoldingCost (lambda (Energy Mass)
- (block (Edens density volume result)
- (setq density 10)
- (setq volume (divide Mass density))
- (setq Edens (divide Energy volume))
- (setq result (divide EDens 10))
- result
- )
- )
- )
- (setq intGetKineticDamage (lambda (mass)
- (block (result)
- (setq result (divide mass 1000))
- result
- )
- )
- )
- (setq typGetShockwaveType (lambda (energy mass)
- (block (edens)
- (setq edens (divide energy (add (multiply 100000 mass) 1)))
- (switch
- (geq edens 10000)
- "singularity"
- (geq edens 1000)
- "graviton"
- (geq edens 500)
- "plasma"
- (geq edens 200)
- "thermo"
- (geq edens 50)
- "blast"
- (geq edens 10)
- "laser"
- "kinetic"
- )
- )
- )
- )
- (setq gorf objGetObjRefData) ;Alias
- (setq sorf objSetObjRefData) ;Alias
- (setq intGetShockwaveRadius (lambda (mass)
- (block (volume result)
- (setq volume (divide mass 1000))
- volume
- )
- )
- )
- (setq intGetShockwaveDamage (lambda (energy mass)
- (block (edens type mind maxd mine maxe)
- (setq edens (divide energy (multiply 100000 mass)))
- (setq type (typGetShockwaveType energy mass))
- (switch
- (eq type "kinetic")
- (block nil
- (setq mind 5)
- (setq maxd 200)
- (setq mine 0)
- (setq maxe 9)
- )
- (eq type "laser")
- (block nil
- (setq mind 1)
- (setq maxd 150)
- (setq mine 10)
- (setq maxe 49)
- )
- (eq type "blast")
- (block nil
- (setq mind 1)
- (setq maxd 99)
- (setq mine 50)
- (setq maxe 199)
- )
- (eq type "thermo")
- (block nil
- (setq mind 10)
- (setq maxd 300)
- (setq mine 200)
- (setq maxe 499)
- )
- (eq type "plasma")
- (block nil
- (setq mind 0)
- (setq maxd 200)
- (setq mine 500)
- (setq maxe 999)
- )
- (eq type "graviton")
- (block nil
- (setq mind 0)
- (setq maxd 800)
- (setq mine 1000)
- (setq maxe 9999)
- )
- (eq type "singularity")
- (block nil
- (setq mind 350)
- (setq maxd 2147483647) ;Going to infinity
- (setq mine 10000)
- (setq maxe 2147483647) ;Going to infinity
- )
- )
- (setq result (add mind (subtract maxe (divide edens (divide (subtract maxe mine) (subtract maxd mind)))))) ;mind + (maxe - (edens / ((maxe - mine) / (maxd - mind))))
- result
- )
- )
- )
- (setq istMakeEMCWeapon (lambda (energy mass)
- (block (freshWeapon)
- (if (eq (isError (itmCreate (typDynamicUNID (cat energy mass)) 1)) True)
- (typCreate (typDynamicUNID (cat energy mass)) (subst (typGetStaticData &itEMC; "Weapon")
- {
- kdamage: (cat "kinetic:" (intGetKineticDamage mass) )
- sdamage: (cat (typGetShockwaveType energy mass) ":" (intGetShockwaveDamage energy mass))
- radius: (intGetShockwaveRadius mass)
- }
- )
- )
- )
- (setq freshWeapon (itmCreate (typDynamicUNID (cat energy mass)) 1))
- freshWeapon
- )
- )
- )
- )
- </Globals>
- <!--
- So. EMC:
- 1. Watts (W)
- 2. Kilograms (KG)
- 3. Status (0 - not ready, 1 - gathering energy, 2 - ready)
- 4. (global one) VirtualWeapon UNID
- -->
- <ItemType UNID="&itEMC;"
- name = "Energy-Matter converter"
- level = "8"
- value = "75000"
- frequency = "veryrare"
- numberAppearing= "1"
- mass = "1000"
- attributes = "MajorItem; Military; EMC;"
- >
- <Invoke key="V" installedOnly="1">
- (scrShowScreen gScreen &dsEMC;)
- </Invoke>
- <Events>
- <OnInstall>
- (block (ds)
- (setq ds (sysCreateStation &stEMCDataStore; 0))
- (objSetObjRefData gSource "EMC_parent" ds)
- (objSetObjRefData ds "parent" gSource)
- (objSetObjRefData ds "this" ds)
- (objSetData ds "EMC_mode" 0)
- (objSetData ds "EMC_W" 0)
- (objSetData ds "EMC_LW" 0)
- (objSetData ds "EMC_kg" 0)
- )
- </OnInstall>
- </Events>
- <StaticData>
- <Weapon>
- <![CDATA[
- <ItemType
- name = "EMC"
- virtual = "true"
- >
- <Weapon
- type= "missile"
- damage= "%kdamage%"
- fireRate= "1"
- hitpoints= "200"
- missileSpeed= "30"
- lifetime= "5000"
- powerUse= "0"
- >
- <Fragment
- type= "area"
- damage= "%sdamage%"
- expansionSpeed= "30"
- missileSpeed= "0"
- lifetime= "%radius%"
- >
- <Effect>
- <Shockwave fadeStart="50">
- <Image imageID= "0x0000F143"
- imageX= "0"
- imageY= "0"
- imageWidth= "512"
- imageHeight= "512"
- imageFrameCount= "1"
- imageTicksPerFrame= "1"/>
- </Shockwave>
- </Effect>
- </Fragment>
- </Weapon>
- </ItemType>
- ]]>
- </Weapon>
- <EnergyLoad>
- <![CDATA[
- <ItemType
- name = "EMC powersink"
- level = "25"
- desc = "Don't disable or uninstall that device from your wiring. %target%"
- >
- <MiscellaneousDevice
- powerUse= "%puse%"
- deviceSlots= "0"
- external= "false"
- />
- <Events>
- <OnUpdate>
- (block (EMC plM currW lastW)
- (setq EMC (objGetObjRefData gSource "EMC_parent"))
- (setq plM (divide (objGetMaxPower gSource) 20))
- (setq currW (objGetData EMC "EMC_W"))
- (setq lastW (subtract (objGetData EMC "EMC_LW") currW))
- (setq currW (add currW plM))
- (if (leq lastW 0)
- (block Nil
- (objFireEvent EMC "Ready")
- (shpRemoveDevice gSource gItem)
- (objRemoveItem gSource gItem)
- )
- (block Nil
- (objSetData EMC "EMC_W" currW)
- )
- )
- )
- </OnUpdate>
- <OnDisable>
- (block (EMC)
- (setq EMC (objGetObjRefData gSource "EMC_parent"))
- (if (eq (objGetData EMC "EMC_mode") 1)
- (block Nil
- (objFireEvent EMC "PowerFailure")
- (shpRemoveDevice gSource gItem)
- (objRemoveItem gSource gItem)
- (dbgOutput "OnDisable")
- )
- )
- )
- </OnDisable>
- <OnUninstall>
- (block (EMC)
- (setq EMC (objGetObjRefData gSource "EMC_parent"))
- (if (eq (objGetData EMC "EMC_mode") 1)
- (block Nil
- (objSetData EMC "EMC_mode" 3)
- (objFireEvent EMC "PowerFailure")
- (shpRemoveDevice gSource gItem)
- (objRemoveItem gSource gItem)
- Nil
- )
- )
- )
- </OnUninstall>
- </Events>
- </ItemType>
- ]]>
- </EnergyLoad>
- </StaticData>
- <MiscellaneousDevice
- powerUse= "0"
- deviceSlots= "1"
- external= "false"
- />
- </ItemType>
- <DockScreen UNID="&dsEMC;"
- name = "Energy-Matter control"
- >
- <Panes>
- <Default>
- <OnPaneInit>
- (block (EMC mode matter)
- (setq EMC (objGetObjRefData gSource "EMC_parent"))
- (setq mode (objGetData EMC "EMC_mode"))
- (setq matter (if (and (geq (objGetData EMC "EMC_W") 0) (geq (objGetData EMC "EMC_kg") 0)) 1 0))
- (scrSetDesc gScreen (subst "Welcome to the EMC controller!\nEMC is %1"
- (switch
- (eq mode 0)
- "awaiting for orders"
- (eq mode 1)
- "gathering energy and can't be used now"
- (eq mode 2)
- "ready to fire"
- )
- )
- )
- (switch
- (eq mode 0)
- (block Nil
- (scrEnableAction gScreen 0 1)
- (scrEnableAction gScreen 1 1)
- (if (eq matter 1)
- (scrEnableAction gScreen 2 1)
- (scrEnableAction gScreen 2 Nil)
- )
- (scrEnableAction gScreen 3 Nil)
- )
- (eq mode 1)
- (block Nil
- (scrEnableAction gScreen 0 Nil)
- (scrEnableAction gScreen 1 Nil)
- (scrEnableAction gScreen 2 Nil)
- (scrEnableAction gScreen 3 Nil)
- )
- (eq mode 2)
- (block Nil
- (scrEnableAction gScreen 0 Nil)
- (scrEnableAction gScreen 1 Nil)
- (scrEnableAction gScreen 2 Nil)
- (scrEnableAction gScreen 3 1)
- )
- )
- )
- </OnPaneInit>
- <Actions>
- <Action name="Add a chunk of matter" key="A">
- (scrShowScreen gScreen &dsEMCMatter;)
- </Action>
- <Action name="Set amount of energy to be collected" key="S">
- (scrShowPane gScreen "Energy")
- </Action>
- <Action name="Begin collecting" key="B">
- (block (psink EMC)
- (setq psink (makePowerSink (divide (objGetMaxPower gSource) 2) 1))
- (objAddItem gSource psink)
- (shpInstallDevice gSource psink)
- (setq EMC (objGetObjRefData gSource "EMC_parent"))
- (objSetData EMC "EMC_mode" 1)
- (scrShowPane gScreen "Default")
- )
- </Action>
- <Action name="Fire" key="F">
- </Action>
- <Action name="Get information" key="G">
- (scrShowPane gScreen "Info")
- </Action>
- <Action name="Read manual" key="R">
- (scrShowPane gScreen "Manual")
- </Action>
- </Actions>
- </Default>
- <Energy showCounter="1" desc="Enter amount of energy that the device will collect, in MW.">
- <Actions>
- <Action name="Set" key="S">
- (block (V EMC)
- (setq V (scrGetCounter gScreen))
- (setq EMC (objGetObjRefData gSource "EMC_parent"))
- (objSetData EMC "EMC_LW" V)
- (scrShowPane gScreen "Default")
- )
- </Action>
- <Action name="Cancel" key="C" cancel="1">
- <ShowPane pane="Default"/>
- </Action>
- </Actions>
- </Energy>
- <Info>
- <OnPaneInit>
- (block (EMC)
- (setq EMC (objGetObjRefData gSource "EMC_parent"))
- (if (eq (objGetData EMC "EMC_refresh") Nil) (objSetData EMC "EMC_refresh" 0))
- (setq W (objGetData EMC "EMC_W"))
- (if (eq W Nil) (setq W 0))
- (setq LW (objGetData EMC "EMC_LW"))
- (if (eq LW Nil) (setq LW 0))
- (setq KG (objGetData EMC "EMC_kg"))
- (if (eq KG Nil) (setq KG 0))
- (setq R (objGetData EMC "EMC_refresh"))
- (scrSetDesc gScreen (subst "Collected mass: %1 kg\nCollected energy: %2 megawatts\nLimit of energy: %3 megawatts" KG W LW))
- (if (eq R 1)
- (sysAddObjTimerEvent 1 EMC "Info")
- )
- )
- )
- </OnPaneInit>
- <Actions>
- <Action name="De/activate refreshing" key="R">
- (objSetData (gorf gSource "EMC_parent") "EMC_refresh" (if (eq (objGetData (gorf gSource "EMC_parent") "EMC_refresh") 1) 0 1))
- <ShowPane pane="Info"/>
- </Action>
- <Action name="Back" cancel="1" key="B">
- (objSetData (gorf gSource "EMC_parent") "EMC_refresh" 0)
- <ShowPane pane="Default"/>
- </Action>
- </Actions>
- </Info>
- <Manual
- desc="This is the EMC manual. Please, choose a page.">
- <Actions>
- <Action name="Page 1" key="1">
- (scrSetDesc gScreen "The EMC is a device that collects energy in some volume. It has 4 special emitters which inserts energy inside a chunk of matter.")
- </Action>
- <Action name="Page 2" key="2">
- (scrSetDesc gScreen "Unfortunately, the device CAN NOT set up it's power consume. After energy is being collected the device will take exactly a half of your maximum power output and you MUST BE ABLE TO HOLD that level until the energy is collected.")
- </Action>
- <Action name="Page 3" key="3">
- (scrSetDesc gScreen "If the device was uninstalled or disabled when it collects power or holds a chunk of matter the chunk will fall on the floor and explodes likely destroying your ship from inside and damage devices.")
- </Action>
- <Action name="Page 4" key="4">
- (scrSetDesc gScreen "There's no way to stop the device from collecting power but disabling it. Pray to Domina the shields will be able to defend you from the explosion")
- </Action>
- <Action name="Back" cancel="1" key="B">
- <ShowPane pane="Default"/>
- </Action>
- </Actions>
- </Manual>
- </Panes>
- </DockScreen>
- <StationType UNID="&stEMCDataStore;"
- name= "(EMC data store)"
- virtual= "1"
- >
- <Events>
- <Info>
- (scrShowScreen gScreen &dsEMC; "Info")
- </Info>
- <Ready>
- (block Nil
- (objSetData gSource "EMC_mode" 2)
- )
- </Ready>
- <PowerFailure>
- (block (loser)
- (setq loser (gorf gSource "parent"))
- (objSetData gSource "EMC_mode" 3)
- (if (eq (objGetData gSource "EMC_kg") 0) (objSetData gSource "EMC_kg" 1)) ;Quite tricky, but better than division by zero
- (istMakeEMCWeapon (objGetData gSource "EMC_W") (objGetData gSource "EMC_kg"))
- (objDamage loser (typDynamicUNID (cat (objGetData gSource "EMC_W") (objGetData gSource "EMC_kg"))) 'playerCreatedExplosion)
- (objSetData gSource "EMC_mode" 0)
- )
- </PowerFailure>
- </Events>
- </StationType>
- <DockScreen UNID="&dsEMCMatter;"
- name = "Reaction chamber"
- type = "itemPicker">
- <ListOptions
- dataFrom = "player"
- list = "*N -EMC"
- />
- <Panes>
- <Default desc="Choose an item to add in the chamber">
- <OnPaneInit>
- (block Nil
- (if (eq gItem Nil)
- (block Nil (scrEnableAction gScreen 0 Nil) (scrSetDesc gScreen "You don't have items which can be added."))
- (scrEnableAction gScreen 0 1)
- )
- )
- </OnPaneInit>
- <Actions>
- <Action name="Add the item" key="A">
- (block (mass EMC)
- (setq mass (itmGetMass gItem))
- (setq EMC (gorf gSource "EMC_parent"))
- (sorf EMC "EMC_kg" (add (gorf EMC "EMC_kg") mass))
- (objRemoveItem gSource gItem)
- )
- <ShowPane pane="Default"/>
- </Action>
- <Action name="Back" cancel="1">
- (scrShowScreen gScreen &dsEMC;)
- </Action>
- </Actions>
- </Default>
- </Panes>
- </Dockscreen>
- </TranscendenceExtension>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement