Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.84 KB | None | 0 0
  1. scn TunaSCMSCScr
  2.  
  3. float fSCVer
  4.  
  5. ref rThis
  6. ref rHI
  7. ref rTgt
  8. ref rSlv
  9. ref rDty
  10. ref rObj
  11. ref rDSB
  12. ref rPrs
  13.  
  14. ;Catchalls
  15. ref cWeap
  16. ref cArmo
  17. ref cAlch
  18. ref cMisc
  19. ref cAmmo
  20.  
  21. int iFlg
  22. int iRtrF
  23.  
  24. int iFunc
  25. int iIdx
  26. int iFoo
  27. int iBar
  28. int iBaz
  29. float fWgt
  30.  
  31. Begin OnActivate
  32. if TunaSCVRQ.iNVSE
  33. if rHI == 0
  34. set rThis to This
  35. set rTgt to GetFirstRef 27 1 0
  36. Label 1
  37. if rTgt.IsScripted
  38. if rTgt.GetScript == TunaSCHIScr
  39. if rTgt.GetDisabled == 0
  40. set rHI to rTgt
  41. endif
  42. endif
  43. endif
  44. if rHI == 0
  45. set rTgt to Pencil01
  46. set rTgt to GetNextRef
  47. if rTgt
  48. Goto 1
  49. endif
  50. endif
  51. if rHI == 0
  52. ; printc "OnActivate Fail! No Homeless Items box for MSC=%n" rThis
  53. Activate
  54. return
  55. endif
  56. endif
  57. if GetGameLoaded
  58. set iFlg to LogicalOr iFlg 16;Set CellEntry
  59. if fSCVer < TunaSCVRQ.fSCVer
  60. set iFlg to LogicalOr iFlg 32;Set DoUpdate
  61. endif
  62. elseif TunaSCVRQ.rMSC != rThis
  63. set iFlg to LogicalOr iFlg 16;Set CellEntry
  64. endif
  65.  
  66. set iFlg to LogicalAnd iFlg 2147483640;Clear isPlayer+isRemote+isCatchAll
  67.  
  68. if IsActionRef rThis
  69. set iFunc to TunaSCVRQ.iFunc
  70. set TunaSCVRQ.iFunc to 0
  71. set rSlv to TunaSCVRQ.rSlv
  72. ; printc "MSC Func=%.0f" iFunc
  73. if iFunc <= 10
  74. ;Designer
  75. if iFunc == 5
  76. set iFlg to LogicalOr iFlg 192;Set DoQBlank+DoDDScan
  77. elseif iFunc == 6
  78. set iFlg to LogicalOr iFlg 256;Set DoDDShow
  79. endif
  80. elseif iFunc <= 40
  81. ;11 to 40
  82. if rSlv.gpc != gpc
  83. set iFlg to LogicalOr iFlg 2;Set isRemote
  84. endif
  85. if iFunc <= 20
  86. ;MenuS
  87. if iFunc == 13
  88. set iFlg to LogicalOr iFlg 8454656;Set DoRead+DoRtrvSlv+DoSort
  89. elseif iFunc == 18
  90. set iFlg to LogicalOr iFlg 8192;Set DoWrite
  91. endif
  92. else
  93. ;Slave Container
  94. if iFunc == 33
  95. ; printc "MSC - Slave Closing"
  96. if LogicalAnd iFlg 33554432;Test PrsEnabled
  97. set iFlg to LogicalOr iFlg 2097152;Set DoSlvOpen
  98. set rSlv to 0
  99. else
  100. return
  101. endif
  102. else
  103. if iFunc == 35
  104. set iFlg to LogicalOr iFlg 2097152;Set DoSlvOpen
  105. elseif iFunc == 34
  106. set iFlg to LogicalOr iFlg 2228224;Set DtySlvLoc+DoSlvOpen
  107. endif
  108. if rSlv == cWeap
  109. set iFlg to LogicalOr iFlg 4;Set isCatchAll
  110. elseif rSlv == cArmo
  111. set iFlg to LogicalOr iFlg 4;Set isCatchAll
  112. elseif rSlv == cAlch
  113. set iFlg to LogicalOr iFlg 4;Set isCatchAll
  114. elseif rSlv == cMisc
  115. set iFlg to LogicalOr iFlg 4;Set isCatchAll
  116. elseif rSlv == cAmmo
  117. set iFlg to LogicalOr iFlg 4;Set isCatchAll
  118. endif
  119. endif
  120. endif
  121. elseif iFunc < 90
  122. ;41 to 89
  123. ;General remote calls.Used 44,45,46,50,70,80,81,85
  124. if iFunc == 80
  125. set iFlg to LogicalOr iFlg 2097152;Set DoSlvOpen
  126. set rSlv to 0
  127. ; elseif iFunc == 81;Make quest up to date
  128. elseif iFunc == 85
  129. set iFlg to LogicalOr iFlg 8388608;Set DoSort
  130. elseif iFunc <= 50
  131. ;Prs routines. 45 - Register rPrs from rSlv. 46/7 MenuM Enable/Disable. 50 - Perk grab. ref of clicked item in TunaSCVRQ.rObj
  132. if iFunc == 50
  133. set iFlg to LogicalOr iFlg 134217728;Set PerkGrab
  134. elseif iFunc == 45
  135. set rPrs to rSlv
  136. return
  137. elseif iFunc == 46
  138. set iFlg to LogicalOr iFlg 100663296;Set PrsEnabled+PrsChanged
  139. elseif iFunc == 47
  140. set iFlg to LogicalOr iFlg 67108864;Set PrsChanged
  141. set iFlg to LogicalAnd iFlg 2113929215;Clear PrsEnabled
  142. elseif iFunc == 44
  143. ;DOB completion callback
  144. if rDSB.GetNumItems == 0
  145. rDSB.MarkForDelete
  146. set rDSB to 0
  147. endif
  148. set iFlg to LogicalOr iFlg 32768;Set DtyDSB
  149. endif
  150. elseif iFunc == 70
  151. set iFlg to LogicalXor iFlg 1073741824;Toggle One-Touch
  152. return
  153. endif
  154. elseif iFunc < 100
  155. ;90 to 99
  156. ;General remote calls.Used 90,91,92-96,99
  157. if iFunc == 99
  158. set iRtrF to TunaSCVRQ.bBtn0
  159. if LogicalAnd iRtrF 4;Test DoOTF
  160. set iFlg to LogicalOr iFlg 262144;Set DoOTF
  161. endif
  162. elseif iFunc == 90
  163. if rDSB == 0
  164. set rDSB to PlaceAtMe TunaSCDSB
  165. rDSB.Disable
  166. if rDSB == 0
  167. ; printc "MSC Fail! No Spawned DSB"
  168. return
  169. endif
  170. endif
  171. set TunaSCVRQ.rSlv to rThis
  172. set TunaSCVRQ.rObj to rDSB
  173. set TunaSCVRQ.iSlvM to 5
  174. PlaceAtMe TunaSCDOB
  175. return
  176. elseif iFunc == 91
  177. if rDSB
  178. if rDSB.IsFormValid
  179. rDSB.MarkForDelete
  180. endif
  181. set rDSB to 0
  182. endif
  183. set iFlg to LogicalOr iFlg 32768;Set DtyDSB
  184. elseif iFunc < 97
  185. ;92 - 96 via MenuM
  186. if rDSB
  187. set iRtrF to 1072693272;Set ForgetMem+MoveToHI+EFL*
  188. else
  189. set iRtrF to 9;Set Everything+ForgetMem
  190. endif
  191. if iFunc == 92
  192. set iRtrF to LogicalOr iRtrF 128;Set Sort
  193. elseif iFunc == 93
  194. set iFlg to LogicalOr iFlg 64;Set DoQBlank
  195. set iRtrF to LogicalOr iRtrF 16;Set MoveToHI
  196. elseif iFunc == 94
  197. set iFlg to LogicalOr iFlg 2048;Set DStoDD
  198. set iRtrF to LogicalOr iRtrF 128;Set Sort
  199. endif
  200. endif
  201. endif
  202. elseif IsActionRef player
  203. if TunaSCVRQ.iFunc == 200
  204. return
  205. endif
  206. set iFlg to LogicalOr iFlg 1;Set isPlayer
  207. set iFunc to 0
  208. set rSlv to 0
  209. set TunaSCVRQ.rSlv to 0
  210. set iFoo to GetControl 27;Grab
  211. if player.IsSneaking
  212. set iFlg to LogicalOr iFlg 17039360;Set DoOTF+DoMenu
  213. elseif IsKeyPressed iFoo
  214. set iFlg to LogicalOr iFlg 17039360;Set DoOTF+DoMenu
  215. elseif LogicalAnd iFlg 1073741824 == 0;Test One-Touch
  216. set iFlg to LogicalOr iFlg 17039360;Set DoOTF+DoMenu
  217. endif
  218. else
  219. return
  220. endif
  221.  
  222. if LogicalAnd iFlg 16;Test CellEntry
  223. set iFlg to LogicalAnd iFlg 2147483631;Clear CellEntry
  224. if GetHasNote TunaSCHlp == 0
  225. AN TunaSCHlp
  226. endif
  227. set TunaSCVRQ.iPSt to 0
  228. if LogicalAnd iFlg 33554432;Test PrsEnabled
  229. if rPrs.IsFormValid == 0
  230. set iFlg to LogicalAnd iFlg 1107296255;Clear PrsEnabled+PrsChanged+PerkGrab+DoPerkList+DoFormLists
  231. set rPrs to 0
  232. endif
  233. endif
  234. if TunaSCVRQ.rMSC != rThis
  235. set TunaSCVRQ.rMSC to rThis
  236. set TunaSCVRQ.rHI to rHI
  237. set TunaSCVRQ.rRCell1 to gpc
  238. set TunaSCVRQ.rRCell2 to 0
  239. set TunaSCVRQ.rRCell3 to 0
  240. set TunaSCVRQ.iStt to 10
  241. if LogicalAnd iFlg 33554432;Test PrsEnabled
  242. set iFlg to LogicalOr iFlg 268435456;Set DoPerkList
  243. endif
  244. endif
  245. if rThis != ListGetNthForm TunaSCOwner 0
  246. ListRemoveNth TunaSCOwner 0
  247. ListAddRef TunaSCOwner 0
  248. set iFlg to LogicalOr iFlg 4882432;Set DtyDSB+DtySlvLoc+DtyOTF+DtyArrays
  249. set iFlg to LogicalAnd iFlg 2146435071;Clear DoMemWipe
  250. SetStage TunaSCFRQ 4
  251. if LogicalAnd iFlg 33554432;Test PrsEnabled
  252. set iFlg to LogicalOr iFlg 536870912;Set DoFormLists
  253. endif
  254. endif
  255. endif
  256. if TunaSCVRQ.iStt > 1
  257. if TunaSCVRQ.iStt == 2
  258. set iFlg to LogicalOr iFlg 512;Set DoRead
  259. elseif TunaSCVRQ.iStt == 3
  260. set iFlg to LogicalOr iFlg 4608;Set DoRead+DoEnabled
  261. elseif TunaSCVRQ.iStt > 3
  262. set iFlg to LogicalOr iFlg 8192;Set DoWrite
  263. endif
  264. endif
  265. if LogicalAnd iFlg 32736;Test DoUpdate+DoQBlank+DoDDScan+DoDDShow+DoRead+DDtoDS+DStoDD+DoEnabled+DoWrite+DoCache
  266. if LogicalAnd iFlg 32;Test DoUpdate
  267. if fSCVer == 0.0
  268. ;Cell has never been used.
  269. set iFlg to LogicalOr iFlg 192;Set DoQBlank+DoDDScan
  270. if iFunc != 5
  271. set iFlg to LogicalOr iFlg 256;Set DoDDShow
  272. endif
  273. endif
  274. set fSCVer to TunaSCVRQ.fSCVer
  275. endif
  276. if LogicalAnd iFlg 64;Test DoQBlank
  277. set iFlg to LogicalOr iFlg 16896;Set DoRead+DoCache
  278. SetStage TunaSCFRQ 15
  279. endif
  280. if LogicalAnd iFlg 128;Test DoDDScan
  281. set iBar to TunaSCVRQ.iSlvM
  282. set rTgt to GetFirstRef 27 1 0
  283. Label 1
  284. if rTgt.IsScripted
  285. if rTgt.GetScript == TunaSCSlvScr
  286. set iFoo to rTgt.GetWeight
  287. if iFoo
  288. if LogicalAND iFoo 1
  289. rTgt.SetWeight 0.0
  290. else
  291. set TunaSCVRQ.rSlv to rTgt
  292. set TunaSCVRQ.iSlvM to iFoo
  293. SetStage TunaSCFRQ 5
  294. endif
  295. endif
  296. endif
  297. endif
  298. set rTgt to Pencil01
  299. set rTgt to GetNextRef
  300. if rTgt
  301. Goto 1
  302. endif
  303. set TunaSCVRQ.rSlv to rSlv
  304. set TunaSCVRQ.iSlvM to iBar
  305. endif
  306. if LogicalAnd iFlg 256;Test DoDDShow
  307. if iFunc == 6
  308. SetStage TunaSCFRQ 7
  309. endif
  310. ;Set Q.iHasDD
  311. SetStage TunaSCFRQ 6
  312. if TunaSCVRQ.iHasDD
  313. ; printc "=== MSC - Designer Defaults Loaded"
  314. SetStage TunaSCFRQ 11
  315. set iFlg to LogicalOr iFlg 1536;Set DoRead+DDtoDS
  316. else
  317. ; printc "MSC - No Designer Defaults Set"
  318. endif
  319. endif
  320. if LogicalAnd iFlg 512;Test DoRead
  321. set iFlg to LogicalAnd iFlg 2147475455;Clear DoWrite
  322. set iFlg to LogicalOr iFlg 16384;Set DoCache
  323. if TunaSCVRQ.iStt > 1
  324. set TunaSCVRQ.iStt to 1
  325. endif
  326. set TunaSCVRQ.iFunc to 1
  327. rHI.Activate rHI 1
  328. endif
  329. if LogicalAnd iFlg 1024;Test DDtoDS
  330. set iFlg to LogicalOr iFlg 4096;Set DoEnabled
  331. set TunaSCVRQ.iFunc to 2
  332. rHI.Activate rHI 1
  333. endif
  334. if LogicalAnd iFlg 2048;Test DStoDD
  335. set iFlg to LogicalOr iFlg 4096;Set DoEnabled
  336. set TunaSCVRQ.iFunc to 3
  337. rHI.Activate rHI 1
  338. endif
  339. if LogicalAnd iFlg 4096;Test DoEnabled
  340. set iFlg to LogicalOr iFlg 24576;Set DoWrite+DoCache
  341. set TunaSCVRQ.iFunc to 4
  342. rHI.Activate rHI 1
  343. endif
  344. if LogicalAnd iFlg 8192;Test DoWrite
  345. set TunaSCVRQ.iFunc to 5
  346. rHI.Activate rHI 1
  347. endif
  348. if LogicalAnd iFlg 16384;Test DoCache
  349. set iFlg to LogicalOr iFlg 4194304;Set DtyArrays
  350. set cWeap to TunaSCVRQ.cWeap
  351. set cArmo to TunaSCVRQ.cArmo
  352. set cAlch to TunaSCVRQ.cAlch
  353. set cMisc to TunaSCVRQ.cMisc
  354. set cAmmo to TunaSCVRQ.cAmmo
  355. endif
  356. set iFlg to LogicalAnd iFlg 2147450911;Clear DoUpdate+DoQBlank+DoDDScan+DoDDShow+DoRead+DDtoDS+DStoDD+DoEnabled+DoWrite+DoCache
  357. endif
  358.  
  359. ;All vars in MSC, HI and Quest should be valid.
  360.  
  361. if iRtrF
  362. set iFlg to LogicalOr iFlg 512;Set DoRead
  363. endif
  364. if LogicalAnd iFlg 1017184769 == 0;Test isPlayer+DoRead+DoRtrvSlv+DoSlvOpen+DoSort+PrsChanged+PerkGrab+DoPerkList+DoFormLists
  365. return
  366. endif
  367.  
  368. if LogicalAnd iFlg 98304;Test DtyDSB+DoRtrvSlv
  369. if LogicalAnd iFlg 32768;Test DtyDSB
  370. Label 1
  371. if ListGetCount TunaSCEFLS
  372. ListRemoveNth TunaSCEFLS 0
  373. Goto 1
  374. endif
  375. if rDSB
  376. if rDSB.IsFormValid
  377. set iIdx to rDSB.GetNumItems
  378. Label 1
  379. if iIdx
  380. set iIdx to iIdx - 1
  381. set rObj to rDSB.GetInventoryObject iIdx
  382. ListAddForm TunaSCEFLS rObj
  383. Goto 1
  384. endif
  385. else
  386. set rDSB to 0
  387. endif
  388. endif
  389. endif
  390. if LogicalAnd iFlg 65536;Test DoRtrvSlv
  391. set iFlg to LogicalOr iFlg 1048576;Set DoMemWipe
  392. if rDSB
  393. if rSlv.GetItemCount TunaSCEFLS
  394. ;Must Avoid Specials
  395. rSlv.RemoveAllTypedItems rThis 1 1 40 TunaSCEFLS
  396. rSlv.RemoveAllTypedItems rThis 1 1 24 TunaSCEFLS
  397. rSlv.RemoveAllTypedItems rThis 1 1 47 TunaSCEFLS
  398. rSlv.RemoveAllTypedItems rThis 1 1 31 TunaSCEFLS
  399. rSlv.RemoveAllTypedItems rThis 1 1 41 TunaSCEFLS
  400. rSlv.RemoveAllTypedItems rThis 1 1 25 TunaSCEFLS
  401. rSlv.RemoveAllTypedItems rThis 1 1 103 TunaSCEFLS
  402. rSlv.RemoveAllTypedItems rThis 1 1 108 TunaSCEFLS
  403. rSlv.RemoveAllTypedItems rThis 1 1 116 TunaSCEFLS
  404. else
  405. ;nothing needs avoiding.
  406. rSlv.RemoveAllItems rThis 1
  407. endif
  408. else
  409. rSlv.RemoveAllItems rThis 1
  410. endif
  411. endif
  412. set iFlg to LogicalAnd iFlg 2147385343;Clear DtyDSB+DoRtrvSlv
  413. endif
  414.  
  415. if LogicalAnd iFlg 2;Test isRemote
  416. return
  417. endif
  418.  
  419. if LogicalAnd iFlg 1017119233 == 0;Test isPlayer+DoRead+DoSlvOpen+DoSort+PrsChanged+PerkGrab+DoPerkList+DoFormLists
  420. return
  421. endif
  422.  
  423. ;The array of local slaves. This will remake the FL's
  424. ;Used in menuM for retrieving. Initialising Memory, and for iRtrF
  425. if LogicalAnd iFlg 131072;Test DtySlvLoc
  426. set iFlg to LogicalAnd iFlg 2147352575;Clear DtySlvLoc
  427. Label 1
  428. if ListGetCount TunaSCSlvCrft
  429. ListRemoveNth TunaSCSlvCrft 0
  430. Goto 1
  431. endif
  432. Label 1
  433. if ListGetCount TunaSCSlv
  434. ListRemoveNth TunaSCSlv 0
  435. Goto 1
  436. endif
  437. set rTgt to GetFirstRef 27 1 0
  438. if rTgt.gpc == gpc
  439. set iBar to 0
  440. else
  441. set iBar to 2
  442. endif
  443. Label 1
  444. if rTgt.IsScripted
  445. if rTgt.GetScript == TunaSCSlvScr
  446. if rTgt.GetDisabled
  447. ;Slave Flags: 1 BitMode, 2 Remote, 4 Disabled
  448. ;set TunaSCVRQ.iFunc to (1 + iBar + 4)
  449. set TunaSCVRQ.iFunc to (5 + iBar)
  450. else
  451. set TunaSCVRQ.iFunc to (1+ iBar)
  452. set iFoo to rTgt.GetWeight
  453. if iFoo
  454. if iFoo > 301
  455. if iFoo < 331
  456. rTgt.ListAddRef TunaSCSlvCrft
  457. endif
  458. endif
  459. endif
  460. rTgt.ListAddRef TunaSCSlv
  461. endif
  462. if rTgt != TunaSCVRQ.rSlv
  463. rTgt.Activate rTgt 1
  464. endif
  465. endif
  466. endif
  467. set rTgt to Pencil01
  468. set rTgt to GetNextRef
  469. if rTgt
  470. Goto 1
  471. endif
  472. set TunaSCVRQ.iFunc to 0
  473. endif
  474.  
  475. if LogicalAnd iFlg 262144;Test DoOTF
  476. if LogicalAnd iFlg 524288;Test DtyOTF
  477. set rTgt to GetFirstRef 27 1 0
  478. Label 1
  479. set iIdx to rTgt.GetNumItems
  480. Label 2
  481. if iIdx
  482. set iIdx to iIdx - 1
  483. set rObj to rTgt.GetInventoryObject iIdx
  484. set iFoo to GetType rObj
  485. if iFoo == 40
  486. if ListGetFormIndex TunaSCScnWeap rObj < 0
  487. ListAddForm TunaSCScnWeap rObj
  488. set iBaz to GetWeaponSkill rObj
  489. if iBaz == 45
  490. ListAddForm TunaSCDSWeapFist rObj
  491. elseif iBaz == 38
  492. ListAddForm TunaSCDSWeapMele rObj
  493. elseif iBaz == 41
  494. ListAddForm TunaSCDSWeapGuns rObj
  495. elseif iBaz == 34
  496. ListAddForm TunaSCDSWeapNRG rObj
  497. elseif iBaz == 35
  498. ListAddForm TunaSCDSWeapExpl rObj
  499. endif
  500. endif
  501. elseif iFoo == 24
  502. if ListGetFormIndex TunaSCScnArmo rObj < 0
  503. ListAddForm TunaSCScnArmo rObj
  504. if IsPA rObj
  505. ListAddForm TunaSCDSArmoPwr rObj
  506. endif
  507. if GetEquipType rObj == 8
  508. ListAddForm TunaSCDSArmoHead rObj
  509. else
  510. set fWgt to GetWeight rObj
  511. if fWgt > 0
  512. if GetArmorDT rObj <= 2
  513. ListAddForm TunaSCDSArmoClot rObj
  514. elseif fWgt <= 15.0
  515. ListAddForm TunaSCDSArmoLgt rObj
  516. elseif fWgt < 30.0
  517. ListAddForm TunaSCDSArmoMed rObj
  518. else
  519. ListAddForm TunaSCDSArmoHvy rObj
  520. endif
  521. endif
  522. endif
  523. endif
  524. elseif iFoo == 47
  525. if ListGetFormIndex TunaSCScnAlch rObj < 0
  526. ListAddForm TunaSCScnAlch rObj
  527. set iBaz to GetEquipType rObj
  528. if iBaz == 10
  529. ListAddForm TunaSCDSAlchChem rObj
  530. elseif iBaz == 11
  531. ListAddForm TunaSCDSAlchAid rObj
  532. elseif iBaz == 12
  533. ListAddForm TunaSCDSAlchFood rObj
  534. elseif iBaz == 13
  535. ListAddForm TunaSCDSAlchAlco rObj
  536. endif
  537. endif
  538. endif
  539. Goto 2
  540. endif
  541. set rTgt to Pencil01
  542. set rTgt to GetNextRef
  543. if rTgt
  544. Goto 1
  545. endif
  546. endif
  547. set iFlg to LogicalAnd iFlg 2146697215;Clear DoOTF+DtyOTF
  548. endif
  549.  
  550. if iRtrF
  551. set iFlg to LogicalAnd iFlg 2147483135;Clear DoRead
  552. if LogicalAnd iRtrF 1;Test Everything
  553. set iIdx to ListGetCount TunaSCSlv
  554. Label 1
  555. if iIdx
  556. set iIdx to iIdx - 1
  557. set rTgt to ListGetNthForm TunaSCSlv iIdx
  558. rTgt.RemoveAllItems rThis 1
  559. Goto 1
  560. endif
  561. rHI.RemoveAllItems rThis 1
  562. if LogicalAnd iRtrF 8;Test ForgetMem
  563. ; if LogicalAnd iFlg 33554432;Test PrsEnabled
  564. ; set iFlg to LogicalOr iFlg 1048576;Set DoMemWipe
  565. ; else
  566. set iFlg to LogicalAnd iFlg 2146435071;Clear DoMemWipe
  567. SetStage TunaSCFRQ 4
  568. ListAddRef TunaSCMem
  569. set rDty to 0
  570. ; endif
  571. endif
  572. else;!Everything
  573. ;Clear Homeless boxes when it makes sense
  574. if cWeap
  575. if LogicalAnd iRtrF 1074791424;Test FiltWeap+EFLWeap+UseMem
  576. cWeap.RemoveAllItems rHI 1
  577. endif
  578. endif
  579. if cArmo
  580. if LogicalAnd iRtrF 1075841024;Test FiltArmo+EFLArmo+UseMem
  581. cArmo.RemoveAllItems rHI 1
  582. endif
  583. endif
  584. if cAlch
  585. if LogicalAnd iRtrF 1077940224;Test FiltAlch+EFLAlch+UseMem
  586. cAlch.RemoveAllItems rHI 1
  587. endif
  588. endif
  589. if cMisc
  590. if LogicalAnd iRtrF 1082138624;Test FiltMisc+EFLMisc+UseMem
  591. cMisc.RemoveAllItems rHI 1
  592. endif
  593. endif
  594. if cAmmo
  595. if LogicalAnd iRtrF 1090535424;Test FiltAmmo+EFLAmmo+UseMem
  596. cAmmo.RemoveAllItems rHI 1
  597. endif
  598. endif
  599. if LogicalAnd iRtrF 2;Test UseTmp
  600. set rSlv to TunaSCTmp
  601. endif
  602. if LogicalAnd iRtrF 1073741824;Test UseMem
  603. set iIdx to ListGetCount rSlv
  604. Label 1
  605. if iIdx
  606. set iIdx to iIdx - 1
  607. set rObj to ListGetNthForm rSlv iIdx
  608. set iFoo to ListGetFormIndex TunaSCMem rObj
  609. if iFoo > -1
  610. ;Found in mem - increase iFoo until we find a locker ref
  611. set iBar to ListGetCount TunaSCMem
  612. Label 2
  613. set iFoo to iFoo + 1
  614. if iFoo < iBar
  615. set rTgt to ListGetNthForm TunaSCMem iFoo
  616. if GetType rTgt == 27
  617. set iBaz to rTgt.GetItemCount rObj
  618. if iBaz
  619. AddItem rObj iBaz 1
  620. rTgt.RemoveItem rObj iBaz 1
  621. set iBar to 0
  622. endif
  623. endif
  624. Goto 2
  625. endif
  626. else
  627. set iBaz to rHI.GetItemCount rObj
  628. if iBaz
  629. AddItem rObj iBaz 1
  630. rHI.RemoveItem rObj iBaz 1
  631. endif
  632. endif
  633. Goto 1
  634. endif
  635. elseif LogicalAnd iRtrF 1073740800;Test Filt* & EFL Masks
  636. RemoveAllItems rHI 1
  637. ;Whole Category
  638. set iFoo to LogicalAnd iRtrF 1072693248;EFL* Mask
  639. if iFoo
  640. set iFoo to RightShift iFoo 20
  641. set iBaz to iFoo
  642. endif
  643. ;Filtered
  644. set iBar to LogicalAnd iRtrF 1047552;Filt* Mask
  645. if iBar
  646. set iBar to RightShift iBar 10
  647. ;don't do filtered of those done by cat
  648. set iBaz to LogicalXor 2147483647 iFoo;Bug workaround for "LogicalNot iFoo"
  649. set iBar to LogicalAnd iBar iBaz
  650. ;common to filtered and by cat.
  651. set iBaz to LogicalOr iFoo iBar
  652. endif
  653. ;Loop containers - Cats
  654. if iFoo
  655. set iIdx to ListGetCount TunaSCSlv
  656. Label 1
  657. if iIdx
  658. set iIdx to iIdx - 1
  659. set rTgt to ListGetNthForm TunaSCSlv iIdx
  660. if LogicalAnd iFoo 1
  661. rTgt.RemoveAllTypedItems rThis 1 1 40 TunaSCEFLS
  662. endif
  663. if LogicalAnd iFoo 2
  664. rTgt.RemoveAllTypedItems rThis 1 1 24 TunaSCEFLS
  665. endif
  666. if LogicalAnd iFoo 4
  667. rTgt.RemoveAllTypedItems rThis 1 1 47 TunaSCEFLS
  668. endif
  669. if LogicalAnd iFoo 8
  670. rTgt.RemoveAllTypedItems rThis 1 1 31 TunaSCEFLS
  671. endif
  672. if LogicalAnd iFoo 16
  673. rTgt.RemoveAllTypedItems rThis 1 1 41 TunaSCEFLS
  674. endif
  675. if LogicalAnd iFoo 32
  676. rTgt.RemoveAllTypedItems rThis 1 1 25 TunaSCEFLS
  677. endif
  678. if LogicalAnd iFoo 64
  679. rTgt.RemoveAllTypedItems rThis 1 1 103 TunaSCEFLS
  680. endif
  681. if LogicalAnd iFoo 128
  682. rTgt.RemoveAllTypedItems rThis 1 1 108 TunaSCEFLS
  683. endif
  684. if LogicalAnd iFoo 256
  685. rTgt.RemoveAllTypedItems rThis 1 1 116 TunaSCEFLS
  686. endif
  687. Goto 1
  688. endif
  689. endif;cat
  690. ;Loop containers - Filtered
  691. if iBar
  692. set iIdx to ListGetCount TunaSCSlv
  693. Label 1
  694. if iIdx
  695. set iIdx to iIdx - 1
  696. set rTgt to ListGetNthForm TunaSCSlv iIdx
  697. if rTgt.GetItemCount rSlv
  698. if LogicalAnd iBar 1
  699. rTgt.RemoveAllTypedItems rThis 1 1 40 TunaSCEFLS
  700. RemoveAllTypedItems rTgt 1 1 40 rSlv
  701. endif
  702. if LogicalAnd iBar 2
  703. rTgt.RemoveAllTypedItems rThis 1 1 24 TunaSCEFLS
  704. RemoveAllTypedItems rTgt 1 1 24 rSlv
  705. endif
  706. if LogicalAnd iBar 4
  707. rTgt.RemoveAllTypedItems rThis 1 1 47 TunaSCEFLS
  708. RemoveAllTypedItems rTgt 1 1 47 rSlv
  709. endif
  710. if LogicalAnd iBar 8
  711. rTgt.RemoveAllTypedItems rThis 1 1 31 TunaSCEFLS
  712. RemoveAllTypedItems rTgt 1 1 31 rSlv
  713. endif
  714. if LogicalAnd iBar 16
  715. rTgt.RemoveAllTypedItems rThis 1 1 41 TunaSCEFLS
  716. RemoveAllTypedItems rTgt 1 1 41 rSlv
  717. endif
  718. if LogicalAnd iBar 32
  719. rTgt.RemoveAllTypedItems rThis 1 1 25 TunaSCEFLS
  720. RemoveAllTypedItems rTgt 1 1 25 rSlv
  721. endif
  722. if LogicalAnd iBar 64
  723. rTgt.RemoveAllTypedItems rThis 1 1 103 TunaSCEFLS
  724. RemoveAllTypedItems rTgt 1 1 103 rSlv
  725. endif
  726. if LogicalAnd iBar 128
  727. rTgt.RemoveAllTypedItems rThis 1 1 108 TunaSCEFLS
  728. RemoveAllTypedItems rTgt 1 1 108 rSlv
  729. endif
  730. if LogicalAnd iBar 256
  731. rTgt.RemoveAllTypedItems rThis 1 1 116 TunaSCEFLS
  732. RemoveAllTypedItems rTgt 1 1 116 rSlv
  733. endif
  734. endif
  735. Goto 1
  736. endif
  737. endif;filter
  738. if LogicalAnd iRtrF 16 == 0;Test MoveToHI unset
  739. ;Common Post
  740. if LogicalAnd iBaz 1
  741. rHI.RemoveAllTypedItems rThis 1 1 40 TunaSCEFL
  742. endif
  743. if LogicalAnd iBaz 2
  744. rHI.RemoveAllTypedItems rThis 1 1 24 TunaSCEFL
  745. endif
  746. if LogicalAnd iBaz 4
  747. rHI.RemoveAllTypedItems rThis 1 1 47 TunaSCEFL
  748. endif
  749. if LogicalAnd iBaz 8
  750. rHI.RemoveAllTypedItems rThis 1 1 31 TunaSCEFL
  751. endif
  752. if LogicalAnd iBaz 16
  753. rHI.RemoveAllTypedItems rThis 1 1 41 TunaSCEFL
  754. endif
  755. if LogicalAnd iBaz 32
  756. rHI.RemoveAllTypedItems rThis 1 1 25 TunaSCEFL
  757. endif
  758. if LogicalAnd iBaz 64
  759. rHI.RemoveAllTypedItems rThis 1 1 103 TunaSCEFL
  760. endif
  761. if LogicalAnd iBaz 128
  762. rHI.RemoveAllTypedItems rThis 1 1 108 TunaSCEFL
  763. endif
  764. if LogicalAnd iBaz 256
  765. rHI.RemoveAllTypedItems rThis 1 1 116 TunaSCEFL
  766. endif
  767. if iBar
  768. ;Filter post
  769. if LogicalAnd iBar 1
  770. RemoveAllTypedItems rHI 1 1 40 rSlv
  771. endif
  772. if LogicalAnd iBar 2
  773. RemoveAllTypedItems rHI 1 1 24 rSlv
  774. endif
  775. if LogicalAnd iBar 4
  776. RemoveAllTypedItems rHI 1 1 47 rSlv
  777. endif
  778. if LogicalAnd iBar 8
  779. RemoveAllTypedItems rHI 1 1 31 rSlv
  780. endif
  781. if LogicalAnd iBar 16
  782. RemoveAllTypedItems rHI 1 1 41 rSlv
  783. endif
  784. if LogicalAnd iBar 32
  785. RemoveAllTypedItems rHI 1 1 25 rSlv
  786. endif
  787. if LogicalAnd iBar 64
  788. RemoveAllTypedItems rHI 1 1 103 rSlv
  789. endif
  790. if LogicalAnd iBar 128
  791. RemoveAllTypedItems rHI 1 1 108 rSlv
  792. endif
  793. if LogicalAnd iBar 256
  794. RemoveAllTypedItems rHI 1 1 116 rSlv
  795. endif
  796. endif
  797. endif;!MoveToHI
  798. if LogicalAnd iRtrF 8;Test ForgetMem
  799. set iFlg to LogicalOr iFlg 1048576;Set DoMemWipe
  800. endif
  801. endif;by cat & filter
  802. if LogicalAnd iRtrF 34 == 2;Test UseTmp == 1 && LeaveTmp == 0
  803. Label 1
  804. if ListGetCount TunaSCTmp
  805. ListRemoveNth TunaSCTmp 0
  806. Goto 1
  807. endif
  808. endif
  809. endif;!Everything
  810. if LogicalAnd iRtrF 16;Test MoveToHI
  811. RemoveAllItems rHI 1
  812. elseif LogicalAnd iRtrF 64;Test OpenMSC
  813. set iRtrF to 0
  814. SetStage TunaSCFRQ 200
  815. return
  816. endif
  817. ;The Sort would stomp on TunaSCTmp
  818. if LogicalAnd iRtrF 160 == 128;Test Sort == 1 && LeaveTmp == 0
  819. set iFlg to LogicalOr iFlg 8388608;Set DoSort
  820. endif
  821. set iRtrF to 0
  822. endif
  823.  
  824. if LogicalAnd iFlg 1017118721 == 0;Test isPlayer+DoSlvOpen+DoSort+PrsChanged+PerkGrab+DoPerkList+DoFormLists
  825. return
  826. endif
  827.  
  828. if LogicalAnd iFlg 1048576;Test DoMemWipe
  829. set iFlg to LogicalAnd iFlg 2146435071;Clear DoMemWipe
  830. SetStage TunaSCFRQ 4
  831. endif
  832.  
  833. if ListGetCount TunaSCMem == 0
  834. set rDty to 0
  835. if LogicalAnd iFlg 4;Test isCatchAll
  836. return
  837. endif
  838. set iFoo to ListGetCount TunaSCSlv
  839. Label 1
  840. if iFoo
  841. set iFoo to iFoo - 1
  842. set rTgt to ListGetNthForm TunaSCSlv iFoo
  843. if rTgt == cWeap
  844. Goto 1
  845. elseif rTgt == cArmo
  846. Goto 1
  847. elseif rTgt == cAlch
  848. Goto 1
  849. elseif rTgt == cMisc
  850. Goto 1
  851. elseif rTgt == cAmmo
  852. Goto 1
  853. endif
  854. set iBaz to 0
  855. set iIdx to rTgt.GetNumItems
  856. Label 2
  857. if iIdx
  858. set iIdx to iIdx - 1
  859. set rObj to rTgt.GetInventoryObject iIdx
  860. set iBar to GetType rObj
  861. if iBar == 24
  862. set iBaz to LogicalOr iBaz 4;Set AddArmo
  863. ListAddForm TunaSCMem2 rObj
  864. elseif iBar == 40
  865. if ListGetFormIndex TunaSCDSWeapThrw rObj > -1
  866. set iBaz to LogicalOr iBaz 1;Set AddMain
  867. ListAddForm TunaSCMem rObj
  868. else
  869. set iBaz to LogicalOr iBaz 2;Set AddWeap
  870. ListAddForm TunaSCMem1 rObj
  871. endif
  872. else
  873. set iBaz to LogicalOr iBaz 1;Set AddMain
  874. ListAddForm TunaSCMem rObj
  875. endif
  876. Goto 2
  877. endif
  878. if LogicalAnd iBaz 1;Test AddMain
  879. rTgt.ListAddRef TunaSCMem
  880. endif
  881. if LogicalAnd iBaz 2;Test AddWeap
  882. rTgt.ListAddRef TunaSCMem1
  883. endif
  884. if LogicalAnd iBaz 4;Test AddArmo
  885. rTgt.ListAddRef TunaSCMem2
  886. endif
  887. Goto 1
  888. endif
  889. if ListGetCount TunaSCMem == 0
  890. ListAddRef TunaSCMem
  891. endif
  892. if LogicalAnd iFlg 33554432;Test PrsEnabled
  893. set iFlg to LogicalOr iFlg 32;Set DoUpdate
  894. endif
  895. endif
  896.  
  897. if rDty
  898. if LogicalAnd iFlg 8;Test DtyCatchAll
  899. set iIdx to rDty.GetNumItems
  900. Label 1
  901. if iIdx
  902. set iIdx to iIdx - 1
  903. set rObj to rDty.GetInventoryObject iIdx
  904. set iFoo to GetType rObj
  905. if iFoo == 24
  906. ListRemoveForm TunaSCMem2 rObj
  907. elseif iFoo == 40
  908. if ListGetFormIndex TunaSCDSWeapThrw rObj > -1
  909. ListRemoveForm TunaSCMem rObj
  910. else
  911. ListRemoveForm TunaSCMem1 rObj
  912. endif
  913. else
  914. ListRemoveForm TunaSCMem rObj
  915. endif
  916. Goto 1
  917. endif
  918. else
  919. set iIdx to rDty.GetNumItems
  920. Label 1
  921. if iIdx
  922. set iIdx to iIdx - 1
  923. set rObj to rDty.GetInventoryObject iIdx
  924. set iFoo to GetType rObj
  925. if iFoo == 24
  926. ListRemoveForm TunaSCMem2 rObj
  927. ListAddForm TunaSCTmp2 rObj
  928. elseif iFoo == 40
  929. if ListGetFormIndex TunaSCDSWeapThrw rObj > -1
  930. ListRemoveForm TunaSCMem rObj
  931. ListAddForm TunaSCTmp rObj
  932. else
  933. ListRemoveForm TunaSCMem1 rObj
  934. ListAddForm TunaSCTmp1 rObj
  935. endif
  936. else
  937. ListRemoveForm TunaSCMem rObj
  938. ListAddForm TunaSCTmp rObj
  939. endif
  940. Goto 1
  941. endif
  942. if ListGetCount TunaSCTmp
  943. ;Find out if a reference to thisbox is already in the formlist... and grab its index
  944. set iBar to -1
  945. set iIdx to ListGetCount TunaSCMem
  946. Label 1
  947. if iIdx
  948. set iIdx to iIdx - 1
  949. set rObj to ListGetNthForm TunaSCMem iIdx
  950. if GetType rObj == 27
  951. ;Found a locker reference
  952. if rObj == rDty
  953. set iBar to iIdx
  954. set iIdx to 0
  955. endif
  956. endif
  957. Goto 1
  958. endif
  959. if iBar < 0
  960. ;Add this locker to front of the list
  961. set iBar to 0
  962. rDty.ListAddRef TunaSCMem 0
  963. endif
  964. ;Add all the Objects to this lockers record
  965. Label 1
  966. set rObj to ListRemoveNth TunaSCTmp 0
  967. ListAddForm TunaSCMem rObj iBar
  968. if ListGetCount TunaSCTmp
  969. Goto 1
  970. endif
  971. endif
  972. if ListGetCount TunaSCTmp1
  973. set iBar to -1
  974. set iIdx to ListGetCount TunaSCMem1
  975. Label 1
  976. if iIdx
  977. set iIdx to iIdx - 1
  978. set rObj to ListGetNthForm TunaSCMem1 iIdx
  979. if GetType rObj == 27
  980. if rObj == rDty
  981. set iBar to iIdx
  982. set iIdx to 0
  983. endif
  984. endif
  985. Goto 1
  986. endif
  987. if iBar < 0
  988. set iBar to 0
  989. rDty.ListAddRef TunaSCMem1 0
  990. endif
  991. Label 1
  992. set rObj to ListRemoveNth TunaSCTmp1 0
  993. ListAddForm TunaSCMem1 rObj iBar
  994. if ListGetCount TunaSCTmp1
  995. Goto 1
  996. endif
  997. endif
  998. if ListGetCount TunaSCTmp2
  999. set iBar to -1
  1000. set iIdx to ListGetCount TunaSCMem2
  1001. Label 1
  1002. if iIdx
  1003. set iIdx to iIdx - 1
  1004. set rObj to ListGetNthForm TunaSCMem2 iIdx
  1005. if GetType rObj == 27
  1006. if rObj == rDty
  1007. set iBar to iIdx
  1008. set iIdx to 0
  1009. endif
  1010. endif
  1011. Goto 1
  1012. endif
  1013. if iBar < 0
  1014. set iBar to 0
  1015. rDty.ListAddRef TunaSCMem2 0
  1016. endif
  1017. Label 1
  1018. set rObj to ListRemoveNth TunaSCTmp2 0
  1019. ListAddForm TunaSCMem2 rObj iBar
  1020. if ListGetCount TunaSCTmp2
  1021. Goto 1
  1022. endif
  1023. endif
  1024. endif
  1025. if LogicalAnd iFlg 33554432;Test PrsEnabled
  1026. set iFlg to LogicalOr iFlg 128;Set DoDDScan
  1027. set TunaSCVRQ.rRCell2 to rDty
  1028. endif
  1029. set rDty to 0
  1030. endif
  1031.  
  1032. ;rPrs Calls
  1033. if LogicalAnd iFlg 33554432;Test PrsEnabled
  1034. if LogicalAnd iFlg 1015021728;Test DoUpdate+DoDDScan+DoSort+PrsChanged+PerkGrab+DoPerkList+DoFormLists
  1035. set TunaSCVRQ.iSlvM to iFlg
  1036. if LogicalAnd iFlg 134217728;Test PerkGrab
  1037. set iFlg to LogicalAnd iFlg 1140850527;Clear DoUpdate+DoDDScan+PrsChanged+PerkGrab+DoPerkList+DoFormLists
  1038. set TunaSCVRQ.rSlv to rPrs
  1039. set TunaSCVRQ.iFunc to 450
  1040. SetStage TunaSCFRQ 201
  1041. return
  1042. else
  1043. set iFlg to LogicalAnd iFlg 1140850527;Clear DoUpdate+DoDDScan+PrsChanged+PerkGrab+DoPerkList+DoFormLists
  1044. set TunaSCVRQ.iFunc to 50
  1045. rPrs.Activate rPrs 1
  1046. endif
  1047. endif
  1048. endif
  1049.  
  1050. if LogicalAnd iFlg 2097152;Test DoSlvOpen
  1051. ; printc "DoSlvOpen"
  1052. set rDty to rSlv
  1053. if LogicalAnd iFlg 4;Test isCatchAll
  1054. set iFlg to LogicalOr iFlg 8;Set DtyCatchAll
  1055. set iFlg to LogicalAnd iFlg 2145386495;Clear DoSlvOpen
  1056. else
  1057. set iFlg to LogicalAnd iFlg 2145386487;Clear DtyCatchAll+DoSlvOpen
  1058. endif
  1059. if rSlv
  1060. ;User may add new items
  1061. set iFlg to LogicalOr iFlg 524288;Set DtyOTF
  1062. endif
  1063. return
  1064. endif
  1065.  
  1066. if LogicalAnd iFlg 8388608;Test DoSort
  1067. if LogicalAnd iFlg 4194304;Test DtyArrays
  1068. set TunaSCVRQ.iFunc to 9
  1069. rHI.Activate rHI 1
  1070. endif
  1071. set iFlg to LogicalAnd iFlg 2134900735;Clear DtyArrays+DoSort
  1072. set TunaSCVRQ.iFunc to 20
  1073. rHI.Activate rHI 1
  1074. endif
  1075.  
  1076. if LogicalAnd iFlg 1 == 0;Test !isPlayer
  1077. return
  1078. endif
  1079.  
  1080. if LogicalAnd iFlg 16777216;Test DoMenu
  1081. set iFlg to LogicalAnd iFlg 2130706431;Clear DoMenu
  1082. if rDSB
  1083. set TunaSCVRQ.iIdx to 1
  1084. set TunaSCVRQ.rObj to rDSB
  1085. else
  1086. set TunaSCVRQ.iIdx to 0
  1087. endif
  1088. if rPrs
  1089. if LogicalAnd iFlg 33554432;Test PrsEnabled
  1090. set TunaSCVRQ.bBtn1 to 2
  1091. else
  1092. set TunaSCVRQ.bBtn1 to 1
  1093. endif
  1094. else
  1095. set TunaSCVRQ.bBtn1 to 0
  1096. endif
  1097. player.AddItem TunaSCMenuMTok 1 1
  1098. return
  1099. endif
  1100.  
  1101. endif
  1102. Activate
  1103. End
  1104.  
  1105. Begin OnClose
  1106. if TunaSCVRQ.iNVSE
  1107. if rHI == 0
  1108. return
  1109. endif
  1110. if LogicalAnd iFlg 4194304;Test DtyArrays
  1111. set TunaSCVRQ.iFunc to 9
  1112. rHI.Activate rHI 1
  1113. endif
  1114. if LogicalAnd iFlg 33554432;Test PrsEnabled
  1115. set TunaSCVRQ.iFunc to 51
  1116. rPrs.Activate rPrs 1
  1117. endif
  1118. set iFlg to LogicalAnd iFlg 2134900735;Clear DtyArrays+DoSort
  1119. set TunaSCVRQ.iFunc to 20
  1120. rHI.Activate rHI 1
  1121. endif
  1122. End
  1123.  
  1124. Begin OnLoad
  1125. if TunaSCVRQ.iNVSE
  1126. set iFlg to LogicalOr iFlg 16;Set CellEntry
  1127. if TunaSCVRQ.fSCVer > fSCVer
  1128. set iFlg to LogicalOr iFlg 32;Set DoUpdate
  1129. endif
  1130. endif
  1131. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement