PageRenderTime 59ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/Python/Cleft.py

https://github.com/boq/moul-scripts
Python | 280 lines | 156 code | 46 blank | 78 comment | 31 complexity | 8a831f74b7bd2c70948a0b85aec31f8f MD5 | raw file
  1. # -*- coding: utf-8 -*-
  2. """ *==LICENSE==*
  3. CyanWorlds.com Engine - MMOG client, server and tools
  4. Copyright (C) 2011 Cyan Worlds, Inc.
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. Additional permissions under GNU GPL version 3 section 7
  16. If you modify this Program, or any covered work, by linking or
  17. combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
  18. NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
  19. JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
  20. (or a modified version of those libraries),
  21. containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
  22. PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
  23. JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
  24. licensors of this Program grant you additional
  25. permission to convey the resulting work. Corresponding Source for a
  26. non-source form of such a combination shall include the source code for
  27. the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
  28. work.
  29. You can contact Cyan Worlds, Inc. by email legal@cyan.com
  30. or by snail mail at:
  31. Cyan Worlds, Inc.
  32. 14617 N Newport Hwy
  33. Mead, WA 99021
  34. *==LICENSE==* """
  35. """
  36. Module: Cleft.py
  37. Age: Cleft
  38. Date: February 2003
  39. Event Manager hooks for Cleft
  40. """
  41. from Plasma import *
  42. from PlasmaTypes import *
  43. from PlasmaConstants import *
  44. from PlasmaKITypes import *
  45. #rgnSnsrFissureDrop = ptAttribActivator(1, "rgn snsr: fissure drop spawn")
  46. respFissureDropStart = ptAttribResponder(1,"resp: fissure drop start")
  47. respFissureDropMain = ptAttribResponder(2,"resp: fissure drop main")
  48. loadTomahna = 0
  49. loadZandi = 0
  50. loadBook = 0
  51. fissureDrop = 0
  52. #kIntroPlayedChronicle = "IntroPlayed"
  53. class Cleft(ptResponder):
  54. def __init__(self):
  55. ptResponder.__init__(self)
  56. self.id = 5209
  57. self.version = 22
  58. #var used to load in Cleft/Tomahna specific stuff based on chronicle vals
  59. global loadTomahna
  60. global loadZandi
  61. global loadBook
  62. loadTomahna = 0
  63. loadZandi = 0
  64. loadBook = 0
  65. #checks chronicle entries, if don't exist or is set to no,
  66. #then decides if Tomahna or Zandi should be paged in
  67. vault = ptVault()
  68. entryCleft = vault.findChronicleEntry("CleftSolved")
  69. if type(entryCleft) != type(None):
  70. entryCleftValue = entryCleft.chronicleGetValue()
  71. if entryCleftValue != "yes":
  72. loadZandi = 1
  73. loadBook = 1
  74. elif type(entryCleft) == type(None):
  75. loadZandi = 1
  76. loadBook = 1
  77. vault = ptVault()
  78. entryTomahna = vault.findChronicleEntry("TomahnaLoad")
  79. if type(entryTomahna) != type(None):
  80. entryTomahnaValue = entryTomahna.chronicleGetValue()
  81. if entryTomahnaValue == "yes":
  82. loadTomahna = 1
  83. if loadZandi:
  84. loadZandi = 0
  85. if loadBook:
  86. loadBook = 0
  87. pages = []
  88. # Add the age specific pages
  89. if loadTomahna:
  90. pages += ["Cleft","tmnaDesert","MaleShortIdle","FemaleShortIdle","YeeshaFinalEncounter","FemaleTurnRight180","MaleTurnRight180","clftSndLogTracks","clftAtrusGoggles"]
  91. else:
  92. pages += ["Desert","Cleft","FemaleCleftDropIn","MaleCleftDropIn","clftJCsDesert","clftJCsChasm"]
  93. if loadZandi:
  94. pages += ["clftZandiVis","ZandiCrossLegs","ZandiDirections","ZandiDirections01","ZandiDirections02","ZandiDirections03"]
  95. pages += ["ZandiIdle","ZandiRubNose","ZandiScratchHead","ZandiTurnPage","ZandiAllFace","ZandiOpen01Face"]
  96. pages += ["ZandiOpen02Face","ZandiRand01Face","ZandiRand02Face","ZandiRand03Face","ZandiRand04Face","ZandiRand05Face"]
  97. pages += ["ZandiRes01aFace","ZandiRes01bFace","ZandiRes02aFace","ZandiRes02bFace","ZandiRes03aFace","ZandiRes03bFace"]
  98. pages += ["ZandiJC01aFace","ZandiJC01bFace","ZandiJC02aFace","ZandiJC02bFace","ZandiJC03aFace","ZandiJC03bFace"]
  99. pages += ["ZandiJC04aFace","ZandiJC04bFace","ZandiJC05aFace","ZandiJC05bFace","ZandiJC06aFace","ZandiJC06bFace"]
  100. pages += ["ZandiJC07aFace","ZandiJC07bFace"]
  101. else:
  102. print "Zandi seems to have stepped away from the Airstream. Hmmm..."
  103. if loadBook:
  104. pages += ["clftYeeshaBookVis","FemaleGetPersonalBook","MaleGetPersonalBook"]
  105. else:
  106. print "Zandi seems to have stepped away from the Airstream. Hmmm..."
  107. # Put in all the common pages
  108. pages += ["BookRoom","clftAtrusNote"]
  109. pages += ["FemaleClimbOffTreeLadder","FemaleGetOnTreeLadder","FemaleWindmillLockedCCW","FemaleWindmillLockedCW","FemaleWindmillStart"]
  110. pages += ["MaleClimbOffTreeLadder","MaleGetOnTreeLadder","MaleWindmillLockedCCW","MaleWindmillLockedCW","MaleWindmillStart"]
  111. pages += ["YeeshaVisionBlocked","YeeshaFinalVision"]
  112. PtPageInNode(pages)
  113. if loadTomahna:
  114. #now that Tomahna pages have loaded, reset its chronicle value back to no,
  115. #so subsequent linking will default to regular Cleft instead of Tomahna,
  116. #unless a Tomahna link is used, of course...
  117. entryTomahna.chronicleSetValue("no")
  118. entryTomahna.save()
  119. pass
  120. def OnFirstUpdate(self):
  121. pass
  122. #~ # test for first time to play the intro movie
  123. #~ vault = ptVault()
  124. #~ entry = vault.findChronicleEntry(kIntroPlayedChronicle)
  125. #~ if type(entry) != type(None):
  126. #~ # already played intro sometime in the past... just let 'em play
  127. #~ PtSendKIMessage(kEnableKIandBB,0)
  128. #~ else:
  129. #~ # make sure the KI and blackbar is still diabled
  130. #~ PtSendKIMessage(kDisableKIandBB,0)
  131. #~ # It's the first time... start the intro movie, just by loading the movie dialog
  132. #~ PtLoadDialog("IntroMovieGUI")
  133. def OnServerInitComplete(self):
  134. global loadTomahna
  135. global fissureDrop
  136. ageSDL = PtGetAgeSDL()
  137. # sets Tomahna SDL based on what is being loaded (thanks to chronicle val)
  138. # also settings previously contained in .fni files
  139. if loadTomahna:
  140. SDLVarName = "clftTomahnaActive"
  141. ageSDL[SDLVarName] = (1,)
  142. PtDebugPrint("Cleft.OnServerInitComplete: loadTomahna is 1, setting clftTomahnaActive SDL to 1")
  143. #PtFogSetDefLinear(start, end, density)
  144. PtFogSetDefLinear(0,0,0)
  145. PtSetClearColor(.4,.4,.5)
  146. SDLVarSceneBahro = "clftSceneBahroUnseen"
  147. boolSceneBahro = ageSDL[SDLVarSceneBahro][0]
  148. if boolSceneBahro:
  149. PtDebugPrint("Cleft.OnServerInitComplete: SDL says bahro hasn't played yet, paging in SceneBahro stuff...")
  150. PtPageInNode("clftSceneBahro")
  151. else:
  152. PtDebugPrint("Cleft.OnServerInitComplete: SDL says SceneBahro already played, will NOT page in")
  153. ageSDL.setNotify(self.key,SDLVarSceneBahro,0.0)
  154. SDLVarSceneYeesha = "clftSceneYeeshaUnseen"
  155. boolSceneYeesha = ageSDL[SDLVarSceneYeesha][0]
  156. if boolSceneYeesha:
  157. #PtDebugPrint("Cleft.OnServerInitComplete: SDL says Yeesha hasn't played yet, paging in SceneYeesha stuff...")
  158. #PtPageInNode("clftSceneYeesha")
  159. SDLVarOfficeDoor = "clftOfficeDoorClosed"
  160. boolOfficeDoor = ageSDL[SDLVarOfficeDoor][0]
  161. if boolOfficeDoor:
  162. PtDebugPrint("Cleft.OnServerInitComplete: SDL says Yeesha will play and office door is shut, will open it")
  163. ageSDL[SDLVarOfficeDoor] = (0,)
  164. else:
  165. PtDebugPrint("Cleft.OnServerInitComplete: SDL says SceneYeesha already played, will NOT page in")
  166. else:
  167. SDLVarName = "clftTomahnaActive"
  168. ageSDL[SDLVarName] = (0,)
  169. PtDebugPrint("Cleft.OnServerInitComplete: loadTomahna is 0, setting clftTomahnaActive SDL set to 0")
  170. PtFogSetDefLinear(0,0,0)
  171. PtSetClearColor(0,0,0)
  172. linkmgr = ptNetLinkingMgr()
  173. link = linkmgr.getCurrAgeLink()
  174. spawnPoint = link.getSpawnPoint()
  175. spTitle = spawnPoint.getTitle()
  176. spName = spawnPoint.getName()
  177. if spName == "LinkInPointFissureDrop":
  178. fissureDrop = 1
  179. #avatar.physics.suppress(false)
  180. avatar = 0
  181. try:
  182. avatar = PtGetLocalAvatar()
  183. except:
  184. print"failed to get local avatar"
  185. return
  186. avatar.avatar.registerForBehaviorNotify(self.key)
  187. cam = ptCamera()
  188. cam.disableFirstPersonOverride()
  189. cam.undoFirstPerson()
  190. PtDisableMovementKeys()
  191. PtSendKIMessage(kDisableEntireYeeshaBook,0)
  192. respFissureDropStart.run(self.key,avatar=PtGetLocalAvatar())
  193. def Load(self):
  194. ageSDL = PtGetAgeSDL()
  195. # If both Kitchen and Office Doors are closed when linking into the age, this will open the Kitchen door.
  196. # It prevents Player from being locked out of Kitchen/Office if both doors were left shut when Player was last there...
  197. SDLVarKitchenDoor = "clftKitchenDoorClosed"
  198. SDLVarOfficeDoor = "clftOfficeDoorClosed"
  199. boolKitchenDoor = ageSDL[SDLVarKitchenDoor][0]
  200. boolOfficeDoor = ageSDL[SDLVarOfficeDoor][0]
  201. if boolKitchenDoor and boolOfficeDoor:
  202. PtDebugPrint("Cleft.OnLoad: both Kitchen and Office doors are closed... setting Kitchen door SDL to open")
  203. ageSDL[SDLVarKitchenDoor] = (0,)
  204. else:
  205. PtDebugPrint("Cleft.OnLoad: either Kitchen and/or Office door is already open... leaving Kitchen door alone")
  206. pass
  207. def OnNotify(self,state,id,events):
  208. global fissureDrop
  209. if (id == respFissureDropMain.id):
  210. print "FISSUREDROP.OnNotify: respFissureDropMain.id callback"
  211. if fissureDrop:
  212. cam = ptCamera()
  213. cam.enableFirstPersonOverride()
  214. fissureDrop = 0
  215. avatar = PtGetLocalAvatar()
  216. avatar.avatar.unRegisterForBehaviorNotify(self.key)
  217. PtEnableMovementKeys()
  218. PtSendKIMessage(kEnableEntireYeeshaBook,0)
  219. def OnBehaviorNotify(self,type,id,state):
  220. global fissureDrop
  221. #PtDebugPrint("Cleft.OnBehaviorNotify(): %d" % (type))
  222. if type == PtBehaviorTypes.kBehaviorTypeLinkIn and not state:
  223. print "FISSUREDROP.OnBehaviorNotify: fissureDrop = %d" % (fissureDrop)
  224. if fissureDrop:
  225. PtDebugPrint("Cleft.OnBehaviorNotify(): will run respFissureDropMain now.")
  226. respFissureDropMain.run(self.key,avatar=PtGetLocalAvatar())