|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +""" *==LICENSE==* |
| 3 | +
|
| 4 | +CyanWorlds.com Engine - MMOG client, server and tools |
| 5 | +Copyright (C) 2011 Cyan Worlds, Inc. |
| 6 | +
|
| 7 | +This program is free software: you can redistribute it and/or modify |
| 8 | +it under the terms of the GNU General Public License as published by |
| 9 | +the Free Software Foundation, either version 3 of the License, or |
| 10 | +(at your option) any later version. |
| 11 | +
|
| 12 | +This program is distributed in the hope that it will be useful, |
| 13 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +GNU General Public License for more details. |
| 16 | +
|
| 17 | +You should have received a copy of the GNU General Public License |
| 18 | +along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | +
|
| 20 | +Additional permissions under GNU GPL version 3 section 7 |
| 21 | +
|
| 22 | +If you modify this Program, or any covered work, by linking or |
| 23 | +combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
| 24 | +NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
| 25 | +JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
| 26 | +(or a modified version of those libraries), |
| 27 | +containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
| 28 | +PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
| 29 | +JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
| 30 | +licensors of this Program grant you additional |
| 31 | +permission to convey the resulting work. Corresponding Source for a |
| 32 | +non-source form of such a combination shall include the source code for |
| 33 | +the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
| 34 | +work. |
| 35 | +
|
| 36 | +You can contact Cyan Worlds, Inc. by email legal@cyan.com |
| 37 | + or by snail mail at: |
| 38 | + Cyan Worlds, Inc. |
| 39 | + 14617 N Newport Hwy |
| 40 | + Mead, WA 99021 |
| 41 | +
|
| 42 | + *==LICENSE==* """ |
| 43 | +""" |
| 44 | +Module: Ahnonay.py |
| 45 | +Age: Ahnonay |
| 46 | +Date: June 2003 |
| 47 | +""" |
| 48 | + |
| 49 | +from Plasma import * |
| 50 | +from PlasmaTypes import * |
| 51 | +from PlasmaNetConstants import * |
| 52 | +from xPsnlVaultSDL import * |
| 53 | + |
| 54 | +spherePages = ["Ahnonay_District_ahnySphere01", |
| 55 | + "Ahnonay_District_ahnySphere02", |
| 56 | + "Ahnonay_District_ahnySphere03", |
| 57 | + "Ahnonay_District_ahnySphere04", |
| 58 | + "Ahnonay_ahnySphere01", |
| 59 | + "Ahnonay_ahnySphere02", |
| 60 | + "Ahnonay_ahnySphere03", |
| 61 | + "Ahnonay_ahnySphere04"] |
| 62 | + |
| 63 | +class Ahnonay(ptResponder): |
| 64 | + |
| 65 | + def __init__(self): |
| 66 | + ptResponder.__init__(self) |
| 67 | + self.id = 5399 |
| 68 | + self.version = 1 |
| 69 | + |
| 70 | + def OnFirstUpdate(self): |
| 71 | + pass |
| 72 | + |
| 73 | + def OnServerInitComplete(self): |
| 74 | + agevault = ptAgeVault() |
| 75 | + ageinfo = agevault.getAgeInfo() |
| 76 | + guid = ageinfo.getAgeInstanceGuid() |
| 77 | + linkid = None |
| 78 | + locked = None |
| 79 | + volatile = None |
| 80 | + spawn = None |
| 81 | + owner = None |
| 82 | + myID = str(PtGetClientIDFromAvatarKey(PtGetLocalAvatar().getKey())) |
| 83 | + |
| 84 | + ageStruct = ptAgeInfoStruct() |
| 85 | + ageStruct.setAgeFilename("Personal") |
| 86 | + |
| 87 | + vault = ptVault() |
| 88 | + ageLinkNode = vault.getOwnedAgeLink(ageStruct) |
| 89 | + if ageLinkNode: |
| 90 | + ageInfoNode = ageLinkNode.getAgeInfo() |
| 91 | + ageInfoChildren = ageInfoNode.getChildNodeRefList() |
| 92 | + for ageInfoChildRef in ageInfoChildren: |
| 93 | + ageInfoChild = ageInfoChildRef.getChild() |
| 94 | + folder = ageInfoChild.upcastToFolderNode() |
| 95 | + if folder and folder.folderGetName() == "AgeData": |
| 96 | + ageDataFolder = folder |
| 97 | + ageDataChildren = folder.getChildNodeRefList() |
| 98 | + for ageDataChildRef in ageDataChildren: |
| 99 | + ageDataChild = ageDataChildRef.getChild() |
| 100 | + chron = ageDataChild.upcastToChronicleNode() |
| 101 | + if chron and chron.getName() == "AhnonayLink": |
| 102 | + linkid = chron |
| 103 | + PtDebugPrint("Ahnonay.OnServerInitComplete(): Link Chron already exists: %s" % (linkid.getValue())) |
| 104 | + elif chron and chron.getName() == "AhnonayLocked": |
| 105 | + locked = chron |
| 106 | + PtDebugPrint("Ahnonay.OnServerInitComplete(): Locked Chron already exists: %s" % (locked.getValue())) |
| 107 | + elif chron and chron.getName() == "AhnonayVolatile": |
| 108 | + volatile = chron |
| 109 | + PtDebugPrint("Ahnonay.OnServerInitComplete(): Volatile Chron already exists: %s" % (volatile.getValue())) |
| 110 | + elif chron and chron.getName() == "AhnonaySpawnPoints": |
| 111 | + spawn = chron |
| 112 | + PtDebugPrint("Ahnonay.OnServerInitComplete(): Spawn Chron already exists: %s" % (spawn.getValue())) |
| 113 | + elif chron and chron.getName() == "AhnonayOwner": |
| 114 | + owner = chron |
| 115 | + break |
| 116 | + |
| 117 | + if owner == None: |
| 118 | + PtDebugPrint("I am not the age owner, and I don't have my own Ahnonay") |
| 119 | + elif owner.getValue() == myID: |
| 120 | + if linkid == None: |
| 121 | + PtDebugPrint("Ahnonay.OnServerInitComplete(): Link Chron not found, creating") |
| 122 | + newNode = ptVaultChronicleNode(0) |
| 123 | + newNode.chronicleSetName("AhnonayLink") |
| 124 | + newNode.chronicleSetValue(guid) |
| 125 | + ageDataFolder.addNode(newNode) |
| 126 | + |
| 127 | + if locked == None: |
| 128 | + PtDebugPrint("Ahnonay.OnServerInitComplete(): Locked Chron not found, creating") |
| 129 | + newNode = ptVaultChronicleNode(0) |
| 130 | + newNode.chronicleSetName("AhnonayLocked") |
| 131 | + newNode.chronicleSetValue("1") |
| 132 | + ageDataFolder.addNode(newNode) |
| 133 | + |
| 134 | + if volatile == None: |
| 135 | + PtDebugPrint("Ahnonay.OnServerInitComplete(): Volatile Chron not found, creating") |
| 136 | + newNode = ptVaultChronicleNode(0) |
| 137 | + newNode.chronicleSetName("AhnonayVolatile") |
| 138 | + newNode.chronicleSetValue("0") |
| 139 | + ageDataFolder.addNode(newNode) |
| 140 | + |
| 141 | + if spawn == None: |
| 142 | + PtDebugPrint("Ahnonay.OnServerInitComplete(): Spawn Chron not found, creating") |
| 143 | + newNode = ptVaultChronicleNode(0) |
| 144 | + newNode.chronicleSetName("AhnonaySpawnPoints") |
| 145 | + newNode.chronicleSetValue("Default,LinkInPointDefault") |
| 146 | + ageDataFolder.addNode(newNode) |
| 147 | + |
| 148 | + if volatile and linkid: |
| 149 | + if volatile.getValue() == "1" and guid != linkid.getValue(): |
| 150 | + PtDebugPrint("Ahnonay.OnServerInitComplete(): In a new instance of Ahnonay so setting new vars") |
| 151 | + linkid.setValue(guid) |
| 152 | + locked.setValue("1") |
| 153 | + volatile.setValue("0") |
| 154 | + spawn.setValue("Default,LinkInPointDefault") |
| 155 | + else: |
| 156 | + PtDebugPrint("I am not the age owner, but I do have my own Ahnonay") |
| 157 | + |
| 158 | + |
| 159 | + ageSDL = PtGetAgeSDL() |
| 160 | + sphere = ageSDL["ahnyCurrentSphere"][0] |
| 161 | + |
| 162 | + if sphere > 4: |
| 163 | + sphere = 1 |
| 164 | + ageSDL["ahnyCurrentSphere"] = (1,) |
| 165 | + |
| 166 | + linkmgr = ptNetLinkingMgr() |
| 167 | + link = linkmgr.getCurrAgeLink() |
| 168 | + spawnPoint = link.getSpawnPoint() |
| 169 | + |
| 170 | + spTitle = spawnPoint.getTitle() |
| 171 | + spName = spawnPoint.getName() |
| 172 | + |
| 173 | + if spTitle == "SCSavePoint": |
| 174 | + if spName == "SaveClothPoint7" or spName == "SaveClothPoint8": |
| 175 | + PtDebugPrint("linking to hub or hut") |
| 176 | + newSphere = 4 |
| 177 | + else: |
| 178 | + offset = str(ageSDL["ahnyCurrentOffset"][0]) |
| 179 | + PtDebugPrint("Ahnonay.OnPageLoad(): Sphere0%s loaded with offset:%s" % (sphere, offset)) |
| 180 | + newSphere = (int(sphere) - int(offset)) % 4 |
| 181 | + if newSphere == 0: |
| 182 | + newSphere = 4 |
| 183 | + else: |
| 184 | + newSphere = sphere |
| 185 | + |
| 186 | + if newSphere == 1: |
| 187 | + PtPageInNode("Sphere01BuildingInterior") |
| 188 | + PtPageInNode("MaintRoom01") |
| 189 | + PtPageInNode("ahnySphere01") |
| 190 | + elif newSphere == 2: |
| 191 | + PtPageInNode("MaintRoom02") |
| 192 | + PtPageInNode("ahnySphere02") |
| 193 | + elif newSphere == 3: |
| 194 | + PtPageInNode("MaintRoom03") |
| 195 | + PtPageInNode("ahnySphere03") |
| 196 | + elif newSphere == 4: |
| 197 | + PtPageInNode("Vortex") |
| 198 | + PtPageInNode("Hub") |
| 199 | + PtPageInNode("MaintRoom04") |
| 200 | + PtPageInNode("EngineerHut") |
| 201 | + PtPageInNode("ahnySphere04") |
| 202 | + |
| 203 | + ########################### |
| 204 | + def OnPageLoad(self,what,who): |
| 205 | + global spherePages |
| 206 | + PtDebugPrint(u"Ahnonay.OnPageLoad(): what={} who={}".format(what, who), level=kDebugDumpLevel) |
| 207 | + |
| 208 | + if what == kLoaded: |
| 209 | + if who in spherePages: |
| 210 | + ageSDL = PtGetAgeSDL() |
| 211 | + sphere = str(ageSDL["ahnyCurrentSphere"][0]) |
| 212 | + offset = str(ageSDL["ahnyCurrentOffset"][0]) |
| 213 | + PtDebugPrint("Ahnonay.OnPageLoad(): Sphere0{} loaded with offset:{}".format(sphere, offset), level=kWarningLevel) |
| 214 | + |
| 215 | + linkmgr = ptNetLinkingMgr() |
| 216 | + link = linkmgr.getCurrAgeLink() |
| 217 | + spawnPoint = link.getSpawnPoint() |
| 218 | + |
| 219 | + spTitle = spawnPoint.getTitle() |
| 220 | + spName = spawnPoint.getName() |
| 221 | + |
| 222 | + if spTitle == "SCSavePoint": |
| 223 | + if spName == "SaveClothPoint7" or spName == "SaveClothPoint8": |
| 224 | + PtDebugPrint("linking to hub or hut") |
| 225 | + newSphere = 4 |
| 226 | + else: |
| 227 | + newSphere = (int(sphere) - int(offset)) % 4 |
| 228 | + if newSphere == 0: |
| 229 | + newSphere = 4 |
| 230 | + spawnPoint = spName + str(newSphere) |
| 231 | + PtGetLocalAvatar().physics.warpObj(PtFindSceneobject(spawnPoint, "Ahnonay").getKey()) |
| 232 | + else: |
| 233 | + defaultLink = "LinkInPointSphere0%s" % (sphere) |
| 234 | + PtGetLocalAvatar().physics.warpObj(PtFindSceneobject(defaultLink, "Ahnonay").getKey()) |
| 235 | + |
| 236 | + ########################### |
| 237 | + def OnNotify(self,state,id,events): |
| 238 | + pass |
| 239 | + |
| 240 | + ########################### |
| 241 | + def OnBackdoorMsg(self, target, param): |
| 242 | + ageSDL = PtGetAgeSDL() |
| 243 | + if target == "sphere": |
| 244 | + if self.sceneobject.isLocallyOwned(): |
| 245 | + ageSDL["ahnyCurrentSphere"] = (int(param),) |
0 commit comments