Advertisement
invention8

Mancala Congkak Papyrus

Mar 23rd, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.83 KB | None | 0 0
  1. Scriptname SAM07_MancalaBoardSpotScript extends ObjectReference
  2.  
  3.  
  4.  
  5. Event OnActivate(ObjectReference akActionRef)
  6.  
  7. ; If Initially moving, then have the board stone count equal moving stone count, then set board stone count equal to zero and trigger next board spot
  8.  
  9.  
  10.  
  11. if SAM_IsPlaying.GetValue() == 1 ; If it is 1, then now we disable the available choices, since it has been picked, and set value to 2
  12.  
  13. if BoardSpotStoneCount >= 1 ; If this is an empty spot, don't go through
  14. SAM_IsPlaying.SetValue(2) ; 2 means that the player's turn is still going on, but player can not interact now.
  15. SAM_PlayerSideChoiceVisibilityRef.Disable(false) ; Disable Player Choices
  16.  
  17. Debug.Notification("BoardSpotStoneCount =" + BoardSpotStoneCount )
  18.  
  19. SAM_MovingStoneCount.SetValue(BoardSpotStoneCount) ; Pick up the stones from this slot. That means transfer integer from slot data to globalvariable
  20. BoardSpotStoneCount = 0
  21.  
  22. NextBoardSpot.Activate(Self) ; Activate next spot in drop mode, which is "2"
  23. PHYDishWoodLSD.Play(Self)
  24.  
  25.  
  26. else
  27.  
  28. ; Show Message notification: "This is an empty slot."
  29.  
  30. SAM_MancalaBoardEmptySlotMessage.Show()
  31.  
  32. endif
  33.  
  34. elseif SAM_IsPlaying.GetValue() == 2 ; this is what plays on each subsequent spot, does not continue from above on same slot since it's elseif
  35.  
  36. Utility.Wait(1.5) ; Wait half a second to slow down the game, more observable to see what's going on, and unclog some script..?
  37.  
  38. if SAM_MovingStoneCount.GetValue() >= 1 ;If we still have stones, keep going, else end the turn
  39.  
  40. if SAM_WhoPlaying.GetValue() == 1 ; This is for the storerooms, big slots on the sides. 1 is 1, 2 is 9, slot wise. Check which side you're playing.
  41.  
  42. If Self != House2 ; House that Player 1 cannot go to.
  43.  
  44. BoardSpotStoneCount = BoardSpotStoneCount + 1 ; Checks to see how many stones are moving, if there's at least one, it takes one from that stone and adds it to this slot's count
  45. SAM_MovingStoneCount.Mod(-1)
  46. PHYDishWoodLSD.Play(SAM_BoardSoundRef)
  47.  
  48. if SAM_MovingStoneCount.GetValue() < 0 ;make sure we don't get a negative here
  49. SAM_MovingStoneCount.SetValue(0)
  50. endif
  51. Debug.Notification("BoardSpotStoneCount =" + BoardSpotStoneCount )
  52.  
  53. NextBoardSpot.Activate(Self) ; continue distribution of stones
  54. else
  55. NextBoardSpot.Activate(Self) ; continue distribution of stones, this is the one that does not drop stones, since it is opponnent's storeroom
  56. endif
  57.  
  58. elseif SAM_WhoPlaying.GetValue() == 2 ; This is for the storerooms, big slots on the sides. 1 is 1, 2 is 9, slot wise. Check which side you're playing.
  59. If Self != House1 ; House that Player 2 cannot go to.
  60.  
  61. BoardSpotStoneCount = BoardSpotStoneCount + 1 ; Checks to see how many stones are moving, if there's at least one, it takes one from that stone and adds it to this slot's count
  62. SAM_MovingStoneCount.Mod(-1)
  63. PHYDishWoodLSD.Play(Self)
  64.  
  65. if SAM_MovingStoneCount.GetValue() < 0 ;make sure we don't get a negative here
  66. SAM_MovingStoneCount.SetValue(0)
  67. endif
  68. Debug.Notification("BoardSpotStoneCount =" + BoardSpotStoneCount )
  69. NextBoardSpot.Activate(Self) ; continue distribution of stones
  70. else
  71. NextBoardSpot.Activate(Self) ; continue distribution of stones, this is the one that does not drop stones, since it is opponnent's storeroom
  72. endif
  73.  
  74. else
  75.  
  76. ; This slot is empty.
  77. ; The other person's turn now.
  78.  
  79. ; This is setting SAM_IsPlaying to 1 because we're currently testing.
  80.  
  81. SAM_IsPlaying.SetValue(1)
  82. SAM_PlayerSideChoiceVisibilityRef.Enable()
  83.  
  84. Debug.Notification("Ended on "+ BoardSpotNumber)
  85.  
  86.  
  87. endif
  88. endif
  89.  
  90. endif
  91.  
  92.  
  93. Utility.Wait(1)
  94.  
  95. ; This section is for the board spot's visual appearance. It enables/disables the stones here depending on how many it has.
  96.  
  97. if BoardSpotStoneCount >= 14
  98. SpotStone14.Enable()
  99. else
  100. SpotStone14.Disable()
  101. endif
  102.  
  103. if BoardSpotStoneCount >= 13
  104. SpotStone13.Enable()
  105. else
  106. SpotStone13.Disable()
  107. endif
  108.  
  109. if BoardSpotStoneCount >= 12
  110. SpotStone12.Enable()
  111. else
  112. SpotStone12.Disable()
  113. endif
  114.  
  115.  
  116. if BoardSpotStoneCount >= 11
  117. SpotStone11.Enable()
  118. else
  119. SpotStone11.Disable()
  120. endif
  121.  
  122. if BoardSpotStoneCount >= 10
  123. SpotStone10.Enable()
  124. else
  125. SpotStone10.Disable()
  126. endif
  127.  
  128. if BoardSpotStoneCount >= 9
  129. SpotStone09.Enable()
  130. else
  131. SpotStone09.Disable()
  132. endif
  133.  
  134. if BoardSpotStoneCount >= 8
  135. SpotStone08.Enable()
  136. else
  137. SpotStone08.Disable()
  138. endif
  139.  
  140.  
  141. if BoardSpotStoneCount >= 7
  142. SpotStone07.Enable()
  143. else
  144. SpotStone07.Disable()
  145. endif
  146.  
  147.  
  148. if BoardSpotStoneCount >= 6
  149. SpotStone06.Enable()
  150. else
  151. SpotStone06.Disable()
  152. endif
  153.  
  154. if BoardSpotStoneCount >= 5
  155. SpotStone05.Enable()
  156. else
  157. SpotStone05.Disable()
  158. endif
  159.  
  160. if BoardSpotStoneCount >= 4
  161. SpotStone04.Enable()
  162. else
  163. SpotStone04.Disable()
  164. endif
  165.  
  166. if BoardSpotStoneCount >= 3
  167. SpotStone03.Enable()
  168. else
  169. SpotStone03.Disable()
  170. endif
  171.  
  172. if BoardSpotStoneCount >= 2
  173. SpotStone02.Enable()
  174. else
  175. SpotStone02.Disable()
  176. endif
  177.  
  178. if BoardSpotStoneCount >= 1
  179. SpotStone01.Enable()
  180. else
  181. SpotStone01.Disable()
  182. endif
  183.  
  184.  
  185.  
  186. ; Build up a store of the references being moved
  187.  
  188. ;MovingMarble01Ref
  189.  
  190. ;Float DestinationSlotXCoord = DestinationSlot.GetXCoord()
  191. ;Float DestinationSlotYCoord = DestinationSlot.GetYCoord()
  192. ;Float DestinationSlotZCoord = DestinationSlot.GetZCoord()
  193.  
  194. ;Float DestinationSlotSpotXCoord = DestinationSlot.GetXCoord()
  195. ;Float DestinationSlotSpotYCoord = DestinationSlot.GetYCoord()
  196. ;Float DestinationSlotSpotZCoord = DestinationSlot.GetZCoord()
  197.  
  198. ;DestinationSlot is defined by the slot this board spot script is attached to
  199.  
  200. ;DestinationSlotSpot is defined by the random selection of a spot using an array
  201.  
  202.  
  203.  
  204.  
  205. ; Generate the slot for our number
  206.  
  207.  
  208.  
  209.  
  210. Int RandomSpotNumber = Utility.RandomInt(1 , 28) ;Randomly pick a number
  211.  
  212.  
  213. string[] myArray = new string[4]
  214.  
  215. if SAM_SlotExistingMarbles01 != None
  216. myArray[0] = "1"
  217. endif
  218.  
  219. if SAM_SlotExistingMarbles02 != None
  220. myArray[0] = "2"
  221. endif
  222.  
  223. if SAM_SlotExistingMarbles03 != None
  224. myArray[0] = "3"
  225. endif
  226.  
  227. if SAM_SlotExistingMarbles04 != None
  228. myArray[0] = "4"
  229. endif
  230.  
  231. if SAM_SlotExistingMarbles05 != None
  232. myArray[0] = "5"
  233. endif
  234.  
  235.  
  236.  
  237.  
  238. ;;;; if RandomSpotNumber == ;an existing spot number for this slot, aka, marble is in the place this wants to be, then manually adjust it
  239.  
  240.  
  241. if myArray.Find(RandomSpotNumber) < 0
  242. Debug.Trace("The Spot Wasn't In Our Array!")
  243. else
  244. Debug.Trace("The Spot Was In Our Array!")
  245. ; Change RandomSpotNumber and then retry, this is why we have array!
  246.  
  247. if RandomSpotNumber < 28
  248. RandomSpotNumber += 1
  249. else
  250. RandomSpotNumber = 1 ;Go back down to One if we're at max
  251. endIf
  252. endif
  253.  
  254.  
  255.  
  256.  
  257.  
  258. if RandomSpotNumber == 1 ;Assign the spots
  259.  
  260. SAM_DestinationSlotSpotRef01 = SAM_DestinationSlotSpot
  261. elseif RandomSpotNumber == 2
  262. SAM_DestinationSlotSpotRef02 = SAM_DestinationSlotSpot
  263. elseif RandomSpotNumber == 3
  264. SAM_DestinationSlotSpotRef03 = SAM_DestinationSlotSpot
  265. elseif RandomSpotNumber == 4
  266. SAM_DestinationSlotSpotRef04 = SAM_DestinationSlotSpot
  267. elseif RandomSpotNumber == 5
  268. SAM_DestinationSlotSpotRef05 = SAM_DestinationSlotSpot
  269. endif
  270.  
  271.  
  272. Float DestinationSlotXCoord = SAM_DestinationSlot.GetPositionX()
  273. Float DestinationSlotYCoord = SAM_DestinationSlot.GetPositionY()
  274. Float DestinationSlotZCoord = SAM_DestinationSlot.GetPositionZ()
  275.  
  276. Float DestinationSlotSpotXCoord = SAM_DestinationSlotSpot.GetPositionX()
  277. Float DestinationSlotSpotYCoord = SAM_DestinationSlotSpot.GetPositionY()
  278. Float DestinationSlotSpotZCoord = SAM_DestinationSlotSpot.GetPositionZ()
  279.  
  280.  
  281. Float SetDestinationSlotSpotXCoord = DestinationSlotSpotXCoord + DestinationSlotXCoord
  282. Float SetDestinationSlotSpotYCoord = DestinationSlotSpotYCoord + DestinationSlotYCoord
  283. Float SetDestinationSlotSpotZCoord = DestinationSlotSpotZCoord + DestinationSlotZCoord
  284.  
  285.  
  286.  
  287.  
  288. ; We use this to derive the position of the House as well as the spot inside the individual House to offset the marble by.
  289.  
  290. ; Make ObjectReferences that are saved as the ones on this spot from RandomInt
  291.  
  292. ; Make ObjectReferences that are defined as the ones in SAM_MancalaMath
  293.  
  294.  
  295.  
  296.  
  297. ;FreeSpots ; These are the spots of the grid that are free.
  298.  
  299.  
  300. ; This will randomly move our marble to a free spot at our destination!
  301.  
  302. ; Or maybe pre-determined, mmmm
  303.  
  304.  
  305.  
  306.  
  307. ;string[] PotentialSpot = new string[28]
  308. ;PotentialSpot [0] = "SAM_MarbleSpot01Ref"
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319. if akActionRef == Game.GetPlayer()
  320. if SAM_IsPlaying.GetValue() == 0
  321. Debug.Notification( BoardSpotStoneCount + " pieces on spot " + BoardSpotNumber)
  322.  
  323. endif
  324. endif
  325.  
  326.  
  327. EndEvent
  328.  
  329.  
  330.  
  331. Int Property BoardSpotNumber Auto
  332.  
  333. Int Property BoardSpotStoneCount Auto
  334.  
  335. ObjectReference Property NextBoardSpot Auto
  336.  
  337. ObjectReference Property SAM_PlayerSideChoiceVisibilityRef Auto
  338.  
  339. GlobalVariable Property SAM_MovingStoneCount Auto
  340.  
  341. GlobalVariable Property SAM_IsPlaying Auto
  342.  
  343. GlobalVariable Property SAM_WhoPlaying Auto
  344.  
  345. ObjectReference Property SpotStone01 Auto
  346.  
  347. ObjectReference Property SpotStone02 Auto
  348.  
  349. ObjectReference Property SpotStone03 Auto
  350.  
  351. ObjectReference Property SpotStone04 Auto
  352.  
  353. ObjectReference Property SpotStone05 Auto
  354.  
  355. ObjectReference Property SpotStone06 Auto
  356.  
  357. ObjectReference Property SpotStone07 Auto
  358.  
  359. ObjectReference Property SpotStone08 Auto
  360.  
  361. ObjectReference Property SpotStone09 Auto
  362.  
  363. ObjectReference Property SpotStone10 Auto
  364.  
  365. ObjectReference Property SpotStone11 Auto
  366.  
  367. ObjectReference Property SpotStone12 Auto
  368.  
  369. ObjectReference Property SpotStone13 Auto
  370.  
  371. ObjectReference Property SpotStone14 Auto
  372.  
  373. ObjectReference Property House1 Auto
  374.  
  375. ObjectReference Property House2 Auto
  376.  
  377. ObjectReference Property SAM_BoardSoundRef Auto
  378.  
  379. Message Property SAM_MancalaBoardEmptySlotMessage Auto
  380.  
  381. Sound Property PHYDishWoodLSD Auto
  382.  
  383. ObjectReference Property SAM_DestinationSlotSpot Auto
  384.  
  385. ObjectReference Property SAM_DestinationSlot Auto
  386.  
  387. ObjectReference Property SAM_DestinationSlotSpotRef01 Auto
  388.  
  389. ObjectReference Property SAM_DestinationSlotSpotRef02 Auto
  390.  
  391. ObjectReference Property SAM_DestinationSlotSpotRef03 Auto
  392.  
  393. ObjectReference Property SAM_DestinationSlotSpotRef04 Auto
  394.  
  395. ObjectReference Property SAM_DestinationSlotSpotRef05 Auto
  396.  
  397. ObjectReference Property SAM_SlotExistingMarbles01 Auto
  398.  
  399. ObjectReference Property SAM_SlotExistingMarbles02 Auto
  400.  
  401. ObjectReference Property SAM_SlotExistingMarbles03 Auto
  402.  
  403. ObjectReference Property SAM_SlotExistingMarbles04 Auto
  404.  
  405. ObjectReference Property SAM_SlotExistingMarbles05 Auto
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement