Advertisement
EditorRUS

EMC

Jan 17th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.49 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <!DOCTYPE TranscendenceExtension
  4. [
  5. <!ENTITY unidExtension "0xEE000000">
  6. <!ENTITY itEMC "0xEE004000">
  7. <!ENTITY stEMCDataStore "0xEE004001">
  8. <!ENTITY dsEMC "0xEE006000">
  9. <!ENTITY dsEMCMatter "0xEE006001">
  10. ]>
  11.  
  12. <TranscendenceExtension
  13. name = "Energy-Matter converter"
  14. credits = "EditorRUS"
  15. version = "1.0"
  16. UNID = "&unidExtension;"
  17. >
  18.  
  19. <Globals>
  20. (block Nil
  21. (setq makePowerSink (lambda (euse target)
  22. (block (powersink)
  23. (if (eq (isError (itmCreate (typDynamicUNID (cat euse target)) 1)) True)
  24. (block Nil
  25. (typCreate (typDynamicUNID (cat euse target)) (subst (typGetStaticData &itEMC; "EnergyLoad")
  26. {
  27. target:
  28. (switch
  29. (eq target 1)
  30. "It's collecting power."
  31. (eq target 2)
  32. "It's taking power for EMC shields."
  33. )
  34. puse: euse
  35. }
  36. )
  37. )
  38. )
  39. )
  40. (setq powersink (itmCreate (typDynamicUNID (cat euse target)) 1))
  41. (dbgOutput "Success 1")
  42. powersink
  43. )
  44. )
  45. )
  46.  
  47. (setq intCalculateMatterHoldingCost (lambda (Energy Mass)
  48. (block (Edens density volume result)
  49. (setq density 10)
  50. (setq volume (divide Mass density))
  51. (setq Edens (divide Energy volume))
  52. (setq result (divide EDens 10))
  53. result
  54. )
  55. )
  56. )
  57.  
  58. (setq intGetKineticDamage (lambda (mass)
  59. (block (result)
  60. (setq result (divide mass 1000))
  61. result
  62. )
  63. )
  64. )
  65.  
  66. (setq typGetShockwaveType (lambda (energy mass)
  67. (block (edens)
  68. (setq edens (divide energy (add (multiply 100000 mass) 1)))
  69. (switch
  70. (geq edens 10000)
  71. "singularity"
  72. (geq edens 1000)
  73. "graviton"
  74. (geq edens 500)
  75. "plasma"
  76. (geq edens 200)
  77. "thermo"
  78. (geq edens 50)
  79. "blast"
  80. (geq edens 10)
  81. "laser"
  82. "kinetic"
  83. )
  84. )
  85. )
  86. )
  87.  
  88. (setq gorf objGetObjRefData) ;Alias
  89. (setq sorf objSetObjRefData) ;Alias
  90.  
  91. (setq intGetShockwaveRadius (lambda (mass)
  92. (block (volume result)
  93. (setq volume (divide mass 1000))
  94. volume
  95. )
  96. )
  97. )
  98.  
  99. (setq intGetShockwaveDamage (lambda (energy mass)
  100. (block (edens type mind maxd mine maxe)
  101. (setq edens (divide energy (multiply 100000 mass)))
  102. (setq type (typGetShockwaveType energy mass))
  103. (switch
  104. (eq type "kinetic")
  105. (block nil
  106. (setq mind 5)
  107. (setq maxd 200)
  108. (setq mine 0)
  109. (setq maxe 9)
  110. )
  111. (eq type "laser")
  112. (block nil
  113. (setq mind 1)
  114. (setq maxd 150)
  115. (setq mine 10)
  116. (setq maxe 49)
  117. )
  118. (eq type "blast")
  119. (block nil
  120. (setq mind 1)
  121. (setq maxd 99)
  122. (setq mine 50)
  123. (setq maxe 199)
  124. )
  125. (eq type "thermo")
  126. (block nil
  127. (setq mind 10)
  128. (setq maxd 300)
  129. (setq mine 200)
  130. (setq maxe 499)
  131. )
  132. (eq type "plasma")
  133. (block nil
  134. (setq mind 0)
  135. (setq maxd 200)
  136. (setq mine 500)
  137. (setq maxe 999)
  138. )
  139. (eq type "graviton")
  140. (block nil
  141. (setq mind 0)
  142. (setq maxd 800)
  143. (setq mine 1000)
  144. (setq maxe 9999)
  145. )
  146. (eq type "singularity")
  147. (block nil
  148. (setq mind 350)
  149. (setq maxd 2147483647) ;Going to infinity
  150. (setq mine 10000)
  151. (setq maxe 2147483647) ;Going to infinity
  152. )
  153. )
  154. (setq result (add mind (subtract maxe (divide edens (divide (subtract maxe mine) (subtract maxd mind)))))) ;mind + (maxe - (edens / ((maxe - mine) / (maxd - mind))))
  155. result
  156. )
  157. )
  158. )
  159.  
  160. (setq istMakeEMCWeapon (lambda (energy mass)
  161. (block (freshWeapon)
  162. (if (eq (isError (itmCreate (typDynamicUNID (cat energy mass)) 1)) True)
  163. (typCreate (typDynamicUNID (cat energy mass)) (subst (typGetStaticData &itEMC; "Weapon")
  164. {
  165. kdamage: (cat "kinetic:" (intGetKineticDamage mass) )
  166. sdamage: (cat (typGetShockwaveType energy mass) ":" (intGetShockwaveDamage energy mass))
  167. radius: (intGetShockwaveRadius mass)
  168. }
  169. )
  170. )
  171. )
  172. (setq freshWeapon (itmCreate (typDynamicUNID (cat energy mass)) 1))
  173. freshWeapon
  174. )
  175. )
  176. )
  177. )
  178. </Globals>
  179.  
  180.  
  181. <!--
  182. So. EMC:
  183. 1. Watts (W)
  184. 2. Kilograms (KG)
  185. 3. Status (0 - not ready, 1 - gathering energy, 2 - ready)
  186. 4. (global one) VirtualWeapon UNID
  187. -->
  188. <ItemType UNID="&itEMC;"
  189. name = "Energy-Matter converter"
  190. level = "8"
  191. value = "75000"
  192. frequency = "veryrare"
  193. numberAppearing= "1"
  194. mass = "1000"
  195. attributes = "MajorItem; Military; EMC;"
  196. >
  197.  
  198. <Invoke key="V" installedOnly="1">
  199. (scrShowScreen gScreen &dsEMC;)
  200. </Invoke>
  201.  
  202. <Events>
  203. <OnInstall>
  204. (block (ds)
  205. (setq ds (sysCreateStation &stEMCDataStore; 0))
  206. (objSetObjRefData gSource "EMC_parent" ds)
  207. (objSetObjRefData ds "parent" gSource)
  208. (objSetObjRefData ds "this" ds)
  209. (objSetData ds "EMC_mode" 0)
  210. (objSetData ds "EMC_W" 0)
  211. (objSetData ds "EMC_LW" 0)
  212. (objSetData ds "EMC_kg" 0)
  213. )
  214. </OnInstall>
  215. </Events>
  216.  
  217. <StaticData>
  218. <Weapon>
  219. <![CDATA[
  220. <ItemType
  221. name = "EMC"
  222. virtual = "true"
  223. >
  224. <Weapon
  225. type= "missile"
  226.  
  227. damage= "%kdamage%"
  228. fireRate= "1"
  229. hitpoints= "200"
  230. missileSpeed= "30"
  231. lifetime= "5000"
  232. powerUse= "0"
  233. >
  234. <Fragment
  235. type= "area"
  236. damage= "%sdamage%"
  237. expansionSpeed= "30"
  238. missileSpeed= "0"
  239. lifetime= "%radius%"
  240. >
  241. <Effect>
  242. <Shockwave fadeStart="50">
  243. <Image imageID= "0x0000F143"
  244. imageX= "0"
  245. imageY= "0"
  246. imageWidth= "512"
  247. imageHeight= "512"
  248. imageFrameCount= "1"
  249. imageTicksPerFrame= "1"/>
  250. </Shockwave>
  251. </Effect>
  252. </Fragment>
  253. </Weapon>
  254. </ItemType>
  255. ]]>
  256. </Weapon>
  257.  
  258. <EnergyLoad>
  259. <![CDATA[
  260. <ItemType
  261. name = "EMC powersink"
  262. level = "25"
  263. desc = "Don't disable or uninstall that device from your wiring. %target%"
  264. >
  265.  
  266. <MiscellaneousDevice
  267. powerUse= "%puse%"
  268. deviceSlots= "0"
  269. external= "false"
  270. />
  271.  
  272. <Events>
  273. <OnUpdate>
  274. (block (EMC plM currW lastW)
  275. (setq EMC (objGetObjRefData gSource "EMC_parent"))
  276. (setq plM (divide (objGetMaxPower gSource) 20))
  277. (setq currW (objGetData EMC "EMC_W"))
  278. (setq lastW (subtract (objGetData EMC "EMC_LW") currW))
  279. (setq currW (add currW plM))
  280. (if (leq lastW 0)
  281. (block Nil
  282. (objFireEvent EMC "Ready")
  283. (shpRemoveDevice gSource gItem)
  284. (objRemoveItem gSource gItem)
  285. )
  286. (block Nil
  287. (objSetData EMC "EMC_W" currW)
  288. )
  289. )
  290. )
  291. </OnUpdate>
  292.  
  293. <OnDisable>
  294. (block (EMC)
  295. (setq EMC (objGetObjRefData gSource "EMC_parent"))
  296. (if (eq (objGetData EMC "EMC_mode") 1)
  297. (block Nil
  298. (objFireEvent EMC "PowerFailure")
  299. (shpRemoveDevice gSource gItem)
  300. (objRemoveItem gSource gItem)
  301. (dbgOutput "OnDisable")
  302.  
  303. )
  304. )
  305. )
  306. </OnDisable>
  307.  
  308. <OnUninstall>
  309. (block (EMC)
  310. (setq EMC (objGetObjRefData gSource "EMC_parent"))
  311. (if (eq (objGetData EMC "EMC_mode") 1)
  312. (block Nil
  313. (objSetData EMC "EMC_mode" 3)
  314. (objFireEvent EMC "PowerFailure")
  315. (shpRemoveDevice gSource gItem)
  316. (objRemoveItem gSource gItem)
  317. Nil
  318. )
  319. )
  320. )
  321. </OnUninstall>
  322. </Events>
  323. </ItemType>
  324. ]]>
  325. </EnergyLoad>
  326. </StaticData>
  327.  
  328. <MiscellaneousDevice
  329. powerUse= "0"
  330. deviceSlots= "1"
  331. external= "false"
  332. />
  333. </ItemType>
  334.  
  335. <DockScreen UNID="&dsEMC;"
  336. name = "Energy-Matter control"
  337. >
  338. <Panes>
  339. <Default>
  340. <OnPaneInit>
  341. (block (EMC mode matter)
  342. (setq EMC (objGetObjRefData gSource "EMC_parent"))
  343. (setq mode (objGetData EMC "EMC_mode"))
  344. (setq matter (if (and (geq (objGetData EMC "EMC_W") 0) (geq (objGetData EMC "EMC_kg") 0)) 1 0))
  345. (scrSetDesc gScreen (subst "Welcome to the EMC controller!\nEMC is %1"
  346. (switch
  347. (eq mode 0)
  348. "awaiting for orders"
  349. (eq mode 1)
  350. "gathering energy and can't be used now"
  351. (eq mode 2)
  352. "ready to fire"
  353. )
  354. )
  355. )
  356. (switch
  357. (eq mode 0)
  358. (block Nil
  359. (scrEnableAction gScreen 0 1)
  360. (scrEnableAction gScreen 1 1)
  361. (if (eq matter 1)
  362. (scrEnableAction gScreen 2 1)
  363. (scrEnableAction gScreen 2 Nil)
  364. )
  365. (scrEnableAction gScreen 3 Nil)
  366. )
  367. (eq mode 1)
  368. (block Nil
  369. (scrEnableAction gScreen 0 Nil)
  370. (scrEnableAction gScreen 1 Nil)
  371. (scrEnableAction gScreen 2 Nil)
  372. (scrEnableAction gScreen 3 Nil)
  373. )
  374. (eq mode 2)
  375. (block Nil
  376. (scrEnableAction gScreen 0 Nil)
  377. (scrEnableAction gScreen 1 Nil)
  378. (scrEnableAction gScreen 2 Nil)
  379. (scrEnableAction gScreen 3 1)
  380. )
  381. )
  382. )
  383. </OnPaneInit>
  384.  
  385. <Actions>
  386. <Action name="Add a chunk of matter" key="A">
  387. (scrShowScreen gScreen &dsEMCMatter;)
  388. </Action>
  389.  
  390. <Action name="Set amount of energy to be collected" key="S">
  391. (scrShowPane gScreen "Energy")
  392. </Action>
  393.  
  394. <Action name="Begin collecting" key="B">
  395. (block (psink EMC)
  396. (setq psink (makePowerSink (divide (objGetMaxPower gSource) 2) 1))
  397. (objAddItem gSource psink)
  398. (shpInstallDevice gSource psink)
  399. (setq EMC (objGetObjRefData gSource "EMC_parent"))
  400. (objSetData EMC "EMC_mode" 1)
  401. (scrShowPane gScreen "Default")
  402. )
  403. </Action>
  404.  
  405. <Action name="Fire" key="F">
  406.  
  407. </Action>
  408.  
  409. <Action name="Get information" key="G">
  410. (scrShowPane gScreen "Info")
  411. </Action>
  412.  
  413. <Action name="Read manual" key="R">
  414. (scrShowPane gScreen "Manual")
  415. </Action>
  416. </Actions>
  417. </Default>
  418.  
  419. <Energy showCounter="1" desc="Enter amount of energy that the device will collect, in MW.">
  420. <Actions>
  421. <Action name="Set" key="S">
  422. (block (V EMC)
  423. (setq V (scrGetCounter gScreen))
  424. (setq EMC (objGetObjRefData gSource "EMC_parent"))
  425. (objSetData EMC "EMC_LW" V)
  426. (scrShowPane gScreen "Default")
  427. )
  428. </Action>
  429.  
  430. <Action name="Cancel" key="C" cancel="1">
  431. <ShowPane pane="Default"/>
  432. </Action>
  433. </Actions>
  434. </Energy>
  435.  
  436. <Info>
  437. <OnPaneInit>
  438. (block (EMC)
  439. (setq EMC (objGetObjRefData gSource "EMC_parent"))
  440. (if (eq (objGetData EMC "EMC_refresh") Nil) (objSetData EMC "EMC_refresh" 0))
  441. (setq W (objGetData EMC "EMC_W"))
  442. (if (eq W Nil) (setq W 0))
  443. (setq LW (objGetData EMC "EMC_LW"))
  444. (if (eq LW Nil) (setq LW 0))
  445. (setq KG (objGetData EMC "EMC_kg"))
  446. (if (eq KG Nil) (setq KG 0))
  447. (setq R (objGetData EMC "EMC_refresh"))
  448. (scrSetDesc gScreen (subst "Collected mass: %1 kg\nCollected energy: %2 megawatts\nLimit of energy: %3 megawatts" KG W LW))
  449. (if (eq R 1)
  450. (sysAddObjTimerEvent 1 EMC "Info")
  451. )
  452. )
  453. )
  454. </OnPaneInit>
  455.  
  456. <Actions>
  457. <Action name="De/activate refreshing" key="R">
  458. (objSetData (gorf gSource "EMC_parent") "EMC_refresh" (if (eq (objGetData (gorf gSource "EMC_parent") "EMC_refresh") 1) 0 1))
  459. <ShowPane pane="Info"/>
  460. </Action>
  461. <Action name="Back" cancel="1" key="B">
  462. (objSetData (gorf gSource "EMC_parent") "EMC_refresh" 0)
  463. <ShowPane pane="Default"/>
  464. </Action>
  465. </Actions>
  466. </Info>
  467.  
  468. <Manual
  469. desc="This is the EMC manual. Please, choose a page.">
  470. <Actions>
  471. <Action name="Page 1" key="1">
  472. (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.")
  473. </Action>
  474.  
  475. <Action name="Page 2" key="2">
  476. (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.")
  477. </Action>
  478.  
  479. <Action name="Page 3" key="3">
  480. (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.")
  481. </Action>
  482.  
  483. <Action name="Page 4" key="4">
  484. (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")
  485. </Action>
  486.  
  487. <Action name="Back" cancel="1" key="B">
  488. <ShowPane pane="Default"/>
  489. </Action>
  490. </Actions>
  491. </Manual>
  492.  
  493. </Panes>
  494. </DockScreen>
  495.  
  496. <StationType UNID="&stEMCDataStore;"
  497. name= "(EMC data store)"
  498. virtual= "1"
  499. >
  500. <Events>
  501. <Info>
  502. (scrShowScreen gScreen &dsEMC; "Info")
  503. </Info>
  504.  
  505. <Ready>
  506. (block Nil
  507. (objSetData gSource "EMC_mode" 2)
  508. )
  509. </Ready>
  510.  
  511. <PowerFailure>
  512. (block (loser)
  513. (setq loser (gorf gSource "parent"))
  514. (objSetData gSource "EMC_mode" 3)
  515. (if (eq (objGetData gSource "EMC_kg") 0) (objSetData gSource "EMC_kg" 1)) ;Quite tricky, but better than division by zero
  516. (istMakeEMCWeapon (objGetData gSource "EMC_W") (objGetData gSource "EMC_kg"))
  517. (objDamage loser (typDynamicUNID (cat (objGetData gSource "EMC_W") (objGetData gSource "EMC_kg"))) 'playerCreatedExplosion)
  518. (objSetData gSource "EMC_mode" 0)
  519. )
  520. </PowerFailure>
  521. </Events>
  522. </StationType>
  523.  
  524. <DockScreen UNID="&dsEMCMatter;"
  525. name = "Reaction chamber"
  526. type = "itemPicker">
  527. <ListOptions
  528. dataFrom = "player"
  529. list = "*N -EMC"
  530. />
  531. <Panes>
  532. <Default desc="Choose an item to add in the chamber">
  533. <OnPaneInit>
  534. (block Nil
  535. (if (eq gItem Nil)
  536. (block Nil (scrEnableAction gScreen 0 Nil) (scrSetDesc gScreen "You don't have items which can be added."))
  537. (scrEnableAction gScreen 0 1)
  538. )
  539. )
  540. </OnPaneInit>
  541. <Actions>
  542. <Action name="Add the item" key="A">
  543. (block (mass EMC)
  544. (setq mass (itmGetMass gItem))
  545. (setq EMC (gorf gSource "EMC_parent"))
  546. (sorf EMC "EMC_kg" (add (gorf EMC "EMC_kg") mass))
  547. (objRemoveItem gSource gItem)
  548. )
  549. <ShowPane pane="Default"/>
  550. </Action>
  551.  
  552. <Action name="Back" cancel="1">
  553. (scrShowScreen gScreen &dsEMC;)
  554. </Action>
  555. </Actions>
  556. </Default>
  557. </Panes>
  558. </Dockscreen>
  559.  
  560. </TranscendenceExtension>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement