def CreatePlayer():
    try:
        Player.byPublicName("ThePlayer")
    except:
        world = World.byName("TheWorld")
        
        #move me
        zone = Zone.byName(world.startZone)
        dzone = Zone.byName(world.dstartZone)
        mzone = Zone.byName(world.mstartZone)
        
        p = Player(publicName="ThePlayer",password="******",fantasyName="ThePlayer",logZone=zone,bindZone=zone,darknessLogZone=dzone,darknessBindZone=dzone,
        monsterLogZone=mzone,monsterBindZone=mzone)

        #temp
        
        t = zone.immTransform
        dt = dzone.immTransform
        mt = mzone.immTransform
        
        p.logTransformInternal= t
        p.bindTransformInternal= t
        p.darknessLogTransformInternal= dt
        p.darknessBindTransformInternal= dt
        p.monsterLogTransformInternal= mt
        p.monsterBindTransformInternal= mt
        
        user = User(name="ThePlayer",password="******")
        user.addRole(Role.byName("Player"))
        user.addRole(Role.byName("Immortal"))
    def perspective_newPlayer(self,publicName,fantasyName, playerPassword = None):
        #XXX if you change this function, also change it's mirror in cserveravatar!!!
        
        if self.world.pwNewPlayer and playerPassword != self.world.pwNewPlayer:
            return (-1,"Incorrect player password.",None)

        #does player already exist?
        try:
            player = Player.byPublicName(publicName)
        except:
            pass
        else:
            return (-1,"You already have an account on this world.",None)
     
        try:
            player = Player.byFantasyName(fantasyName)
        except:
            pass
        else:
            return (-1,"That avatar name is taken, please choose another.",None)
                
        password = GenPasswd().upper()

        #move me
        from mud.world.zone import Zone
        zone = Zone.byName(self.world.startZone)
        dzone = Zone.byName(self.world.dstartZone)
        mzone = Zone.byName(self.world.mstartZone)

        t = zone.immTransform
        dt = dzone.immTransform
        mt = mzone.immTransform
        
        p = Player(publicName=publicName,password=password,fantasyName=publicName,logZone=zone,bindZone=zone,darknessLogZone=dzone,darknessBindZone=dzone,monsterLogZone=mzone,monsterBindZone=mzone)
        #temp
        
        p.logTransformInternal=t
        p.bindTransformInternal=t

        p.darknessLogTransformInternal=dt
        p.darknessBindTransformInternal=dt

        p.monsterLogTransformInternal=mt
        p.monsterBindTransformInternal=mt

        
        user = User(name=publicName,password=password)
        user.addRole(Role.byName("Player"))
        
        if publicName == NewPlayerAvatar.ownerPublicName: 
            user.addRole(Role.byName("Immortal"))
            user.addRole(Role.byName("Guardian"))
            
            return (0,"Immortal Account Created.\nYour password is %s"%password,password)
        
        
        return (0,"Account Created.\nYour password is %s"%password,password)
def SiftZone(zonename):
    from mud.world.zone import Zone
    from mud.world.dialog import Dialog
    from missionsifter import SiftMission

    zone = Zone.byName(zonename)

    print "Sifting zone file: ", zone.missionFile
    spawngroups, dtriggers = SiftMission(zone.missionFile)

    #SPAWNS
    spawns = []
    for sg in zone.spawnGroups:
        #if sg.groupName.upper() in spawngroups: #only do the ones we are actually using
        for si in sg.spawninfos:
            if si.spawn not in spawns:
                spawns.append(si.spawn)

    map(SiftSpawn, spawns)

    #ZONE DIALOG
    for d in dtriggers:
        d = d.replace(r"\'", "'")
        dlg = Dialog.byName(d)
        SiftDialog(dlg)
def IDESetup():
    if not CoreSettings.IDE:
        return
    if CoreSettings.IDE_ZONE:
        z = Zone.byName(CoreSettings.IDE_ZONE)
        p = Player.byPublicName("ThePlayer")
        
        settransform = False
        if p.logZone != z or p.darknessLogZone != z or p.monsterLogZone != z:
            settransform = True
        p.logZone=z
        p.bindZone=z
        p.darknessLogZone=z
        p.darknessBindZone=z
        p.monsterLogZone=z
        p.monsterBindZone=z
        
        if settransform:
            t = z.immTransform
    
            p.logTransformInternal= t
            p.bindTransformInternal= t
            p.darknessLogTransformInternal= t
            p.darknessBindTransformInternal= t
            p.monsterLogTransformInternal= t
            p.monsterBindTransformInternal= t
def SiftZone(zonename):
    from mud.world.zone import Zone
    from mud.world.dialog import Dialog
    from missionsifter import SiftMission

    zone = Zone.byName(zonename)
    
    print "Sifting zone file: ",zone.missionFile
    spawngroups,dtriggers = SiftMission(zone.missionFile)
    
    #SPAWNS
    spawns = []
    for sg in zone.spawnGroups:
        #if sg.groupName.upper() in spawngroups: #only do the ones we are actually using
        for si in sg.spawninfos:
            if si.spawn not in spawns:
                spawns.append(si.spawn)
    
    map(SiftSpawn,spawns)
    
    #ZONE DIALOG
    for d in dtriggers:
        d = d.replace(r"\'","'")
        dlg = Dialog.byName(d)
        SiftDialog(dlg)
def IDESetup():
    if not CoreSettings.IDE:
        return
    if CoreSettings.IDE_ZONE:
        z = Zone.byName(CoreSettings.IDE_ZONE)
        p = Player.byPublicName("ThePlayer")

        settransform = False
        if p.logZone != z or p.darknessLogZone != z or p.monsterLogZone != z:
            settransform = True
        p.logZone = z
        p.bindZone = z
        p.darknessLogZone = z
        p.darknessBindZone = z
        p.monsterLogZone = z
        p.monsterBindZone = z

        if settransform:
            t = z.immTransform

            p.logTransformInternal = t
            p.bindTransformInternal = t
            p.darknessLogTransformInternal = t
            p.darknessBindTransformInternal = t
            p.monsterLogTransformInternal = t
            p.monsterBindTransformInternal = t
Beispiel #7
0
    def createPlayer(self, publicName, code):
        #from newplayeravatar import NewPlayerAvatar
        #XXX if you change this function, also change it's mirror in cserveravatar!!!

        password = GenPasswd().upper()

        #move me
        zone = Zone.byName(self.world.startZone)
        dzone = Zone.byName(self.world.dstartZone)
        mzone = Zone.byName(self.world.mstartZone)

        t = zone.immTransform
        dt = dzone.immTransform
        mt = mzone.immTransform

        p = Player(publicName=publicName,
                   password=password,
                   fantasyName=publicName,
                   logZone=zone,
                   bindZone=zone,
                   darknessLogZone=dzone,
                   darknessBindZone=dzone,
                   monsterLogZone=mzone,
                   monsterBindZone=mzone)
        #temp

        p.logTransformInternal = t
        p.bindTransformInternal = t

        p.darknessLogTransformInternal = dt
        p.darknessBindTransformInternal = dt

        p.monsterLogTransformInternal = mt
        p.monsterBindTransformInternal = mt

        user = User(name=publicName, password=password)
        user.addRole(Role.byName("Player"))

        if code == 2:
            user.addRole(Role.byName("Immortal"))
            user.addRole(Role.byName("Guardian"))
        elif code == 1:
            user.addRole(Role.byName("Guardian"))

        return p
    def createPlayer(self,publicName,code):
        #from newplayeravatar import NewPlayerAvatar
        #XXX if you change this function, also change it's mirror in cserveravatar!!!

                
        password = GenPasswd().upper()

        #move me
        zone = Zone.byName(self.world.startZone)
        dzone = Zone.byName(self.world.dstartZone)
        mzone = Zone.byName(self.world.mstartZone)
        
        t = zone.immTransform
        dt = dzone.immTransform
        mt = mzone.immTransform
        
        p = Player(publicName=publicName,password=password,fantasyName=publicName,logZone=zone,bindZone=zone,darknessLogZone=dzone,darknessBindZone=dzone,monsterLogZone=mzone,monsterBindZone=mzone)
        #temp
        
        p.logTransformInternal=t
        p.bindTransformInternal=t

        p.darknessLogTransformInternal=dt
        p.darknessBindTransformInternal=dt

        p.monsterLogTransformInternal=mt
        p.monsterBindTransformInternal=mt

        
        user = User(name=publicName,password=password)
        user.addRole(Role.byName("Player"))
        
        if code == 2: 
            user.addRole(Role.byName("Immortal"))
            user.addRole(Role.byName("Guardian"))
        elif code == 1:
            user.addRole(Role.byName("Guardian"))
            
            
        return p
def CreatePlayer():
    try:
        Player.byPublicName("ThePlayer")
    except:
        world = World.byName("TheWorld")

        #move me
        zone = Zone.byName(world.startZone)
        dzone = Zone.byName(world.dstartZone)
        mzone = Zone.byName(world.mstartZone)

        p = Player(publicName="ThePlayer",
                   password="******",
                   fantasyName="ThePlayer",
                   logZone=zone,
                   bindZone=zone,
                   darknessLogZone=dzone,
                   darknessBindZone=dzone,
                   monsterLogZone=mzone,
                   monsterBindZone=mzone)

        #temp

        t = zone.immTransform
        dt = dzone.immTransform
        mt = mzone.immTransform

        p.logTransformInternal = t
        p.bindTransformInternal = t
        p.darknessLogTransformInternal = dt
        p.darknessBindTransformInternal = dt
        p.monsterLogTransformInternal = mt
        p.monsterBindTransformInternal = mt

        user = User(name="ThePlayer", password="******")
        user.addRole(Role.byName("Player"))
        user.addRole(Role.byName("Immortal"))
def SiftBattle(name):
    from mud.world.battle import BattleGroup,BattleSequence,BattleResult,BattleMustSurvive,BattleProto
    from mud.world.zone import Zone
    bp = BattleProto.byName(name)
    
    zone = Zone.byName(bp.zoneName)
    
    sequences = []
    seq = bp.side1StartSequence
    while seq:
        sequences.append(seq)
        seq = seq.nextSequence
    seq = bp.side2StartSequence
    while seq:
        sequences.append(seq)
        seq = seq.nextSequence
        
    sgroups = []
    for s in sequences:
        snd = s.zoneSound
        if snd:
            AddSound("./$/data/sound/%s"%snd)
        for g in s.battleGroups:
            if g.triggerSpawnGroup:
                for sg in zone.spawnGroups:
                    if sg.groupName == g.triggerSpawnGroup:
                        sgroups.append(sg)
                        
            if g.spawnGroup:
                for sg in zone.spawnGroups:
                    if sg.groupName == g.spawnGroup:
                        sgroups.append(sg)
        
    
    SiftBattleResult(zone,bp.side1VictoryResult)
    SiftBattleResult(zone,bp.side2VictoryResult)
    SiftBattleResult(zone,bp.side1DefeatResult)
    SiftBattleResult(zone,bp.side2DefeatResult)
    
    for sg in sgroups:
        for sinfo in sg.spawninfos:
            SiftSpawn(sinfo.spawn)
def SiftBattle(name):
    from mud.world.battle import BattleGroup, BattleSequence, BattleResult, BattleMustSurvive, BattleProto
    from mud.world.zone import Zone
    bp = BattleProto.byName(name)

    zone = Zone.byName(bp.zoneName)

    sequences = []
    seq = bp.side1StartSequence
    while seq:
        sequences.append(seq)
        seq = seq.nextSequence
    seq = bp.side2StartSequence
    while seq:
        sequences.append(seq)
        seq = seq.nextSequence

    sgroups = []
    for s in sequences:
        snd = s.zoneSound
        if snd:
            AddSound("./$/data/sound/%s" % snd)
        for g in s.battleGroups:
            if g.triggerSpawnGroup:
                for sg in zone.spawnGroups:
                    if sg.groupName == g.triggerSpawnGroup:
                        sgroups.append(sg)

            if g.spawnGroup:
                for sg in zone.spawnGroups:
                    if sg.groupName == g.spawnGroup:
                        sgroups.append(sg)

    SiftBattleResult(zone, bp.side1VictoryResult)
    SiftBattleResult(zone, bp.side2VictoryResult)
    SiftBattleResult(zone, bp.side1DefeatResult)
    SiftBattleResult(zone, bp.side2DefeatResult)

    for sg in sgroups:
        for sinfo in sg.spawninfos:
            SiftSpawn(sinfo.spawn)
Beispiel #12
0
    def spawnDedicatedZone(self, simAvatar, zoneName, simPort):
        if zoneName == 'any':
            #we pick
            znames = [zone.name for zone in self.zones]
            #list of all instances
            zinstances = []
            for zi in self.liveZoneInstances:
                zinstances.append(zi)
            for zi in self.waitingZoneInstances:
                zinstances.append(zi)

            for zi in zinstances:
                if zi.zone.name in znames:
                    znames.remove(zi.zone.name)

            if not len(znames):
                #all zones served
                raise "all zones server, this isn't actually an error... eventually we serve another zone instance, based on waiting etc"

            zoneName = znames[0]
        else:
            #let's see if we launched this zone
            for zi in self.waitingZoneInstances:
                if zi.port == simPort:
                    return zi

        #this is a dedicated server that has been launched remotely,
        #shouldn't happen for right now... so we'll assert
        traceback.print_stack()
        print "AssertionError: dedicated server launched remotely, shouldn't happen for now!"
        return

        zone = Zone.byName(zoneName)
        #hrm
        ip = self.zoneIP  #see world server main.py
        simPassword = ""
        z = ZoneInstance(zone, ip, simPort, simPassword, None)
        z.time = self.time
        self.waitingZoneInstances.append(z)
        return z
 def spawnDedicatedZone(self,simAvatar,zoneName,simPort):
     if zoneName == 'any':
         #we pick
         znames = [zone.name for zone in self.zones]
         #list of all instances
         zinstances = []
         for zi in self.liveZoneInstances:
             zinstances.append(zi)
         for zi in self.waitingZoneInstances:
             zinstances.append(zi)
             
         for zi in zinstances:
             if zi.zone.name in znames:
                 znames.remove(zi.zone.name)
                 
         if not len(znames):
             #all zones served
             raise "all zones server, this isn't actually an error... eventually we serve another zone instance, based on waiting etc"
             
         zoneName = znames[0]
     else:
         #let's see if we launched this zone
         for zi in self.waitingZoneInstances:
             if zi.port == simPort:
                 return zi
         
     #this is a dedicated server that has been launched remotely, 
     #shouldn't happen for right now... so we'll assert
     traceback.print_stack()
     print "AssertionError: dedicated server launched remotely, shouldn't happen for now!"
     return
     
     zone = Zone.byName(zoneName)
     #hrm
     ip = self.zoneIP #see world server main.py
     simPassword = ""
     z = ZoneInstance(zone,ip,simPort,simPassword,None)
     z.time = self.time
     self.waitingZoneInstances.append(z)
     return z
    def perspective_newPlayer(self,
                              publicName,
                              fantasyName,
                              playerPassword=None):
        #XXX if you change this function, also change it's mirror in cserveravatar!!!

        if self.world.pwNewPlayer and playerPassword != self.world.pwNewPlayer:
            return (-1, "Incorrect player password.", None)

        #does player already exist?
        try:
            player = Player.byPublicName(publicName)
        except:
            pass
        else:
            return (-1, "You already have an account on this world.", None)

        try:
            player = Player.byFantasyName(fantasyName)
        except:
            pass
        else:
            return (-1, "That avatar name is taken, please choose another.",
                    None)

        password = GenPasswd().upper()

        #move me
        from mud.world.zone import Zone
        zone = Zone.byName(self.world.startZone)
        dzone = Zone.byName(self.world.dstartZone)
        mzone = Zone.byName(self.world.mstartZone)

        t = zone.immTransform
        dt = dzone.immTransform
        mt = mzone.immTransform

        p = Player(publicName=publicName,
                   password=password,
                   fantasyName=publicName,
                   logZone=zone,
                   bindZone=zone,
                   darknessLogZone=dzone,
                   darknessBindZone=dzone,
                   monsterLogZone=mzone,
                   monsterBindZone=mzone)
        #temp

        p.logTransformInternal = t
        p.bindTransformInternal = t

        p.darknessLogTransformInternal = dt
        p.darknessBindTransformInternal = dt

        p.monsterLogTransformInternal = mt
        p.monsterBindTransformInternal = mt

        user = User(name=publicName, password=password)
        user.addRole(Role.byName("Player"))

        if publicName == NewPlayerAvatar.ownerPublicName:
            user.addRole(Role.byName("Immortal"))
            user.addRole(Role.byName("Guardian"))

            return (0, "Immortal Account Created.\nYour password is %s" %
                    password, password)

        return (0, "Account Created.\nYour password is %s" % password,
                password)
    def install(self):
        if not FROMGAME:
            print "Installing Player: %s"%self.dbAttr["publicName"]
        
        # Restore log and bind zone data for the three realms.
        try:
            bindZone = Zone.byName(self.bindZone)
            logZone = Zone.byName(self.logZone)
        except:
            bindZone = Zone.byName(self.world.startZone)
            logZone = Zone.byName(self.world.startZone)
            self.dbAttr["bindTransformInternal"] = bindZone.immTransform
            self.dbAttr["logTransformInternal"] = logZone.immTransform
        try:
            darknessBindZone = Zone.byName(self.darknessBindZone)
            darknessLogZone = Zone.byName(self.darknessLogZone)
        except:
            darknessBindZone = Zone.byName(self.world.dstartZone)
            darknessLogZone = Zone.byName(self.world.dstartZone)
            self.dbAttr["darknessBindTransformInternal"] = darknessBindZone.immTransform
            self.dbAttr["darknessLogTransformInternal"] = darknessLogZone.immTransform
        try:
            monsterBindZone = Zone.byName(self.monsterBindZone)
            monsterLogZone = Zone.byName(self.monsterLogZone)
        except:
            monsterBindZone = Zone.byName(self.world.mstartZone)
            monsterLogZone = Zone.byName(self.world.mstartZone)
            self.dbAttr["monsterBindTransformInternal"] = monsterBindZone.immTransform
            self.dbAttr["monsterLogTransformInternal"] = monsterLogZone.immTransform
        #todo, initial monster before live

        self.dbAttr["bindZoneID"]=bindZone.id
        self.dbAttr["logZoneID"]=logZone.id
        self.dbAttr["darknessBindZoneID"]=darknessBindZone.id
        self.dbAttr["darknessLogZoneID"]=darknessLogZone.id
        self.dbAttr["monsterBindZoneID"]=monsterBindZone.id
        self.dbAttr["monsterLogZoneID"]=monsterLogZone.id
        
        FilterColumns(Player,self.dbAttr)
        player = Player(**self.dbAttr)
        
        # Restore character data on this player.
        for c in self.characters:
            c.install(player)
        
        # Restore monster spawn data on this player.
        for f in self.mspawns:
            f.install(player)
        
        # Restore bank items of this player.
        for i in self.items:
            i.install(player,bank=True)
Beispiel #16
0
    def install(self):
        if not FROMGAME:
            print "Installing Player: %s" % self.dbAttr["publicName"]

        # Restore log and bind zone data for the three realms.
        try:
            bindZone = Zone.byName(self.bindZone)
            logZone = Zone.byName(self.logZone)
        except:
            bindZone = Zone.byName(self.world.startZone)
            logZone = Zone.byName(self.world.startZone)
            self.dbAttr["bindTransformInternal"] = bindZone.immTransform
            self.dbAttr["logTransformInternal"] = logZone.immTransform
        try:
            darknessBindZone = Zone.byName(self.darknessBindZone)
            darknessLogZone = Zone.byName(self.darknessLogZone)
        except:
            darknessBindZone = Zone.byName(self.world.dstartZone)
            darknessLogZone = Zone.byName(self.world.dstartZone)
            self.dbAttr[
                "darknessBindTransformInternal"] = darknessBindZone.immTransform
            self.dbAttr[
                "darknessLogTransformInternal"] = darknessLogZone.immTransform
        try:
            monsterBindZone = Zone.byName(self.monsterBindZone)
            monsterLogZone = Zone.byName(self.monsterLogZone)
        except:
            monsterBindZone = Zone.byName(self.world.mstartZone)
            monsterLogZone = Zone.byName(self.world.mstartZone)
            self.dbAttr[
                "monsterBindTransformInternal"] = monsterBindZone.immTransform
            self.dbAttr[
                "monsterLogTransformInternal"] = monsterLogZone.immTransform
        #todo, initial monster before live

        self.dbAttr["bindZoneID"] = bindZone.id
        self.dbAttr["logZoneID"] = logZone.id
        self.dbAttr["darknessBindZoneID"] = darknessBindZone.id
        self.dbAttr["darknessLogZoneID"] = darknessLogZone.id
        self.dbAttr["monsterBindZoneID"] = monsterBindZone.id
        self.dbAttr["monsterLogZoneID"] = monsterLogZone.id

        FilterColumns(Player, self.dbAttr)
        player = Player(**self.dbAttr)

        # Restore character data on this player.
        for c in self.characters:
            c.install(player)

        # Restore monster spawn data on this player.
        for f in self.mspawns:
            f.install(player)

        # Restore bank items of this player.
        for i in self.items:
            i.install(player, bank=True)
def CreateZonePages():
    climate = {
        RPG_CLIMATE_POLAR: 'Polar',
        RPG_CLIMATE_TROPICAL: 'Tropical',
        RPG_CLIMATE_TEMPERATE: 'Temperate',
        RPG_CLIMATE_DRY: 'Dry',
        RPG_CLIMATE_COLD: 'Cold'
    }
    
    indexPage = '%META:TOPICINFO{author="JoshRitter" date="1121799107" format="1.0" version="1.1"}%\n'
    indexPage += "---+ Zone Index\n\n"
    
    FocusLootDetailPage = """
---+ Enchanting Focus Loot Details

In every zone that allows for focus drops there is a slight chance to get a focus from all mobs living in that zone. The special zone foci are especially rare.
The dropped foci have a random variety in quality [[FocusMergingDetails][(Focus Merging Details)]]. Higher quality is significantly rarer. The special zone foci always come at maximum quality.
Raw focus types are never dropped and can only be gained through disenchanting.


---++ Zones in which to find Foci
"""
    
    
    #ZONES
    for zone in Zone.select(orderBy = "niceName"):
        page = ZonePage
        addToFocusPage = zone.name in ZONE_ENCHANTINGITEMS
        
        TWIKINAME = GetTWikiName(zone.niceName)
        indexPage+="\t* [[Zone%s][%s]]\n"%(TWIKINAME,zone.niceName)
        if addToFocusPage:
            FocusLootDetailPage += "\n\n---++++ [[Zone%s][%s]]\n \t*Raw Type:* %s <br> \t*Random Foci:* <br>"%(TWIKINAME,zone.niceName,ZONE_ENCHANTINGITEMS[zone.name][0].split(' of ',1)[0])
            for focusName in ZONE_ENCHANTINGITEMS[zone.name][:-1]:
                FocusLootDetailPage += "\t\t    %s (%s) <br>"%(focusName,ENCHANT_FocusPowersNice[focusName.split(' of ',1)[1]])
            specialFocus = ZONE_ENCHANTINGITEMS[zone.name][-1]
            FocusLootDetailPage += " \t*Special Focus:* %s (%s) <br>"%(specialFocus,ENCHANT_FocusPowersNice[specialFocus.split(' of ',1)[1]])
        
        DESCTEXT = "*Climate:* "+climate[zone.climate]+"<br>\n"
        b = (int(zone.xpMod*100)-100)
        if b:
            DESCTEXT += "*Experience Bonus:* %i%%<br>"%b
        
        spawns = set(si.spawn for sg in zone.spawnGroups for si in sg.spawninfos)
        SPAWNTEXT = GenSpawnText(spawns)
        items = set(lootitem.itemProto for s in spawns if s.lootProto for lootitem in s.lootProto.lootItems)
        LOOTTEXT = ', '.join('[[Item%s][%s]]'%(GetTWikiName(item.name),item.name) for item in sorted(items,key=lambda obj:obj.name))
        
        page = page.replace("^^DESCTEXT^^",DESCTEXT)
        page = page.replace("^^ZONENAME^^",zone.niceName)
        page = page.replace("^^SPAWNTEXT^^",SPAWNTEXT)
        page = page.replace("^^LOOTTEXT^^",LOOTTEXT)
        
        f = file("./distrib/twiki/data/MoMWorld/Zone%s.txt"%TWIKINAME,"w")
        f.write(page)
        f.close()
    
    
    f = file("./distrib/twiki/data/MoMWorld/ZoneIndex.txt","w")
    f.write(indexPage)
    f.close()
    f = file("./distrib/twiki/data/MoMWorld/FocusLootDetails.txt","w")
    f.write(FocusLootDetailPage)
    f.close()
def CreateZonePages():
    climate = {
        RPG_CLIMATE_POLAR: 'Polar',
        RPG_CLIMATE_TROPICAL: 'Tropical',
        RPG_CLIMATE_TEMPERATE: 'Temperate',
        RPG_CLIMATE_DRY: 'Dry',
        RPG_CLIMATE_COLD: 'Cold'
    }

    indexPage = '%META:TOPICINFO{author="JoshRitter" date="1121799107" format="1.0" version="1.1"}%\n'
    indexPage += "---+ Zone Index\n\n"

    FocusLootDetailPage = """
---+ Enchanting Focus Loot Details

In every zone that allows for focus drops there is a slight chance to get a focus from all mobs living in that zone. The special zone foci are especially rare.
The dropped foci have a random variety in quality [[FocusMergingDetails][(Focus Merging Details)]]. Higher quality is significantly rarer. The special zone foci always come at maximum quality.
Raw focus types are never dropped and can only be gained through disenchanting.


---++ Zones in which to find Foci
"""

    #ZONES
    for zone in Zone.select(orderBy="niceName"):
        page = ZonePage
        addToFocusPage = zone.name in ZONE_ENCHANTINGITEMS

        TWIKINAME = GetTWikiName(zone.niceName)
        indexPage += "\t* [[Zone%s][%s]]\n" % (TWIKINAME, zone.niceName)
        if addToFocusPage:
            FocusLootDetailPage += "\n\n---++++ [[Zone%s][%s]]\n \t*Raw Type:* %s <br> \t*Random Foci:* <br>" % (
                TWIKINAME, zone.niceName,
                ZONE_ENCHANTINGITEMS[zone.name][0].split(' of ', 1)[0])
            for focusName in ZONE_ENCHANTINGITEMS[zone.name][:-1]:
                FocusLootDetailPage += "\t\t    %s (%s) <br>" % (
                    focusName, ENCHANT_FocusPowersNice[focusName.split(
                        ' of ', 1)[1]])
            specialFocus = ZONE_ENCHANTINGITEMS[zone.name][-1]
            FocusLootDetailPage += " \t*Special Focus:* %s (%s) <br>" % (
                specialFocus, ENCHANT_FocusPowersNice[specialFocus.split(
                    ' of ', 1)[1]])

        DESCTEXT = "*Climate:* " + climate[zone.climate] + "<br>\n"
        b = (int(zone.xpMod * 100) - 100)
        if b:
            DESCTEXT += "*Experience Bonus:* %i%%<br>" % b

        spawns = set(si.spawn for sg in zone.spawnGroups
                     for si in sg.spawninfos)
        SPAWNTEXT = GenSpawnText(spawns)
        items = set(lootitem.itemProto for s in spawns if s.lootProto
                    for lootitem in s.lootProto.lootItems)
        LOOTTEXT = ', '.join(
            '[[Item%s][%s]]' % (GetTWikiName(item.name), item.name)
            for item in sorted(items, key=lambda obj: obj.name))

        page = page.replace("^^DESCTEXT^^", DESCTEXT)
        page = page.replace("^^ZONENAME^^", zone.niceName)
        page = page.replace("^^SPAWNTEXT^^", SPAWNTEXT)
        page = page.replace("^^LOOTTEXT^^", LOOTTEXT)

        f = file("./distrib/twiki/data/MoMWorld/Zone%s.txt" % TWIKINAME, "w")
        f.write(page)
        f.close()

    f = file("./distrib/twiki/data/MoMWorld/ZoneIndex.txt", "w")
    f.write(indexPage)
    f.close()
    f = file("./distrib/twiki/data/MoMWorld/FocusLootDetails.txt", "w")
    f.write(FocusLootDetailPage)
    f.close()
Beispiel #19
0
    def startZoneProcess(self, zoneName, dynamic=True):
        port = None
        for x in xrange(self.zoneStartPort, self.zoneStartPort + 100):
            if x in self.usedZonePorts:
                continue
            port = x
            self.usedZonePorts.append(x)
            break

        if port == None:
            traceback.print_stack()
            print "AssertionError: no port assigned!"
            return

        zone = Zone.byName(zoneName)
        #hrm
        ip = self.zoneIP  #see world server main.py
        simPassword = ""
        z = ZoneInstance(zone, ip, port, simPassword, None)
        z.world = self
        z.time = self.time
        z.dynamic = dynamic

        self.waitingZoneInstances.append(z)

        if self.frozen:
            cmd = r'..\bin\ZoneServer.exe'
            args = ""
        else:
            cmd = sys.executable
            path = os.getcwd()
            args = r'%s/zoneserver.py' % path

        args += r' -dedicated'
        args += r' -serverport %i -zone %s -world %s -worldport %i' % (
            port, zoneName, self.multiName, self.worldPort)
        if dynamic:
            args += r' -dynamic'

        for arg in sys.argv:
            if arg.startswith("gameconfig="):
                args += " %s" % arg

        if sys.platform[:6] != "darwin":
            # Just don't provide cluster number via gameconfig until
            #  MoM uses gameconfig as well.
            args += r' -cluster=%i' % self.clusterNum
            s = 'start "%s" %s %s' % (os.getcwd(), cmd, args)
            s = os.path.normpath(s)
            print s
            os.system(s)

        else:
            if arg.startswith("-wx"):
                args += " -wx"

            cmd = sys.executable
            args = args.split(" ")
            args.insert(0, cmd)
            s = 'pythonw -c \'import os;os.spawnv(os.P_NOWAIT,"%s",[%s])\'' % (
                cmd, ','.join('"%s"' % arg for arg in args))
            print s
            os.system(s)

        return z
Beispiel #20
0
    def onZoneTrigger(self, player, zoneLink):
        zoneName = zoneLink.dstZoneName

        # If the player who has triggered a zone trigger is trading, then cancel
        # the trade.  This is important so that a Character buffer does not get
        # extracted before a trade is accepted.  If this was to occur, then the
        # buffer sent to another cluster may contain an item that was traded
        # while waiting for the daemon to respond.
        if player.trade:
            player.trade.cancel()

        if CoreSettings.PGSERVER:
            if not self.allowConnections:
                player.backupItems()

                #we're shutting down, so log out character
                if player.darkness:
                    player.darknessLogTransformInternal = zoneLink.dstZoneTransform
                    player.darknessLogZone = Zone.byName(zoneLink.dstZoneName)
                elif player.monster:
                    player.monsterLogTransformInternal = zoneLink.dstZoneTransform
                    player.monsterLogZone = Zone.byName(zoneLink.dstZoneName)
                else:
                    player.logTransformInternal = zoneLink.dstZoneTransform
                    player.logZone = Zone.byName(zoneLink.dstZoneName)

                publicName, pbuffer, cbuffer, cvalues = ExtractPlayer(
                    player.publicName, player.id, player.party.members[0].id,
                    False)
                pbuffer = encodestring(dumps(pbuffer, 2))
                cbuffer = encodestring(dumps(cbuffer, 2))

                player.transfering = True
                from mud.world.cserveravatar import AVATAR
                AVATAR.mind.callRemote("savePlayerBuffer", \
                    publicName,pbuffer,cbuffer,cvalues)

                player.extract = False
                self.kickPlayer(player)
                return

            elif zoneName not in self.staticZoneNames:
                # we need to transfer
                player.prepForZoneOut()
                player.zone.removePlayer(player)
                player.zone = None

                if player.darkness:
                    player.darknessLogTransformInternal = zoneLink.dstZoneTransform
                    player.darknessLogZone = Zone.byName(zoneLink.dstZoneName)
                elif player.monster:
                    player.monsterLogTransformInternal = zoneLink.dstZoneTransform
                    player.monsterLogZone = Zone.byName(zoneLink.dstZoneName)
                else:
                    player.logTransformInternal = zoneLink.dstZoneTransform
                    player.logZone = Zone.byName(zoneLink.dstZoneName)

                publicName, pbuffer, cbuffer, cvalues = ExtractPlayer(
                    player.publicName, player.id, player.party.members[0].id,
                    False)
                pbuffer = encodestring(dumps(pbuffer, 2))
                cbuffer = encodestring(dumps(cbuffer, 2))

                player.transfering = True
                aname = player.publicName
                if player.alliance:
                    aname = player.alliance.remoteLeaderName
                else:
                    print "Warning: Player %s has no alliance on zone trigger, could mess up alliances!!!!!" % player.publicName

                from mud.world.cserveravatar import AVATAR

                guildInfo = (player.guildName, player.guildInfo,
                             player.guildMOTD, player.guildRank)
                d = AVATAR.mind.callRemote("transferPlayer", \
                    player.publicName,pbuffer,player.party.members[0].name, \
                    cbuffer,zoneName,cvalues,aname,guildInfo)
                d.addCallback(self.playerTransfered,
                              [player.party.members[0].name], player)
                return

        zone = Zone.byName(zoneName)

        if self.singlePlayer:
            self.closeZone(player.zone)

        allzi = []
        allzi.extend(self.liveZoneInstances)
        allzi.extend(self.waitingZoneInstances)

        zoptions = []

        if not self.singlePlayer:
            found = False
            for zi in allzi:
                if zi.zone == zone:
                    found = True
                    break
            if not found:
                allzi.append(self.startZoneProcess(zoneName))

        for zi in allzi:
            if zi.zone == zone:
                zo = ZoneOption()
                zo.zoneName = zoneName
                zo.zoneInstanceName = zi.name
                if zi.owningPlayer:
                    zo.owner = zi.owningPlayer.fantasyName
                else:
                    zo.owner = None  # dedicated
                zo.status = zi.status
                zoptions.append(zo)

        player.prepForZoneOut()
        player.zone.removePlayer(player)
        player.zone = None

        # can be a spell trigger too
        player.triggeredZoneLink = zoneLink
        player.triggeredZoneOptions = zoptions  #store zone options (these need to expire)

        player.mind.callRemote("setZoneOptions", zoptions)
 def onZoneTrigger(self,player,zoneLink):
     zoneName = zoneLink.dstZoneName
     
     # If the player who has triggered a zone trigger is trading, then cancel
     # the trade.  This is important so that a Character buffer does not get
     # extracted before a trade is accepted.  If this was to occur, then the
     # buffer sent to another cluster may contain an item that was traded
     # while waiting for the daemon to respond.
     if player.trade:
         player.trade.cancel()
     
     if CoreSettings.PGSERVER:
         if not self.allowConnections:
             player.backupItems()
             
             #we're shutting down, so log out character
             if player.darkness:
                 player.darknessLogTransformInternal = zoneLink.dstZoneTransform
                 player.darknessLogZone = Zone.byName(zoneLink.dstZoneName)
             elif player.monster:
                 player.monsterLogTransformInternal = zoneLink.dstZoneTransform
                 player.monsterLogZone = Zone.byName(zoneLink.dstZoneName)
             else:
                 player.logTransformInternal = zoneLink.dstZoneTransform
                 player.logZone = Zone.byName(zoneLink.dstZoneName)
             
             publicName,pbuffer,cbuffer,cvalues = ExtractPlayer(player.publicName,player.id,player.party.members[0].id,False)
             pbuffer = encodestring(dumps(pbuffer, 2))
             cbuffer = encodestring(dumps(cbuffer, 2))
             
             player.transfering = True
             from mud.world.cserveravatar import AVATAR
             AVATAR.mind.callRemote("savePlayerBuffer", \
                 publicName,pbuffer,cbuffer,cvalues)
             
             player.extract = False
             self.kickPlayer(player)
             return
         
         elif zoneName not in self.staticZoneNames:
             # we need to transfer
             player.prepForZoneOut()
             player.zone.removePlayer(player)
             player.zone = None
             
             if player.darkness:
                 player.darknessLogTransformInternal = zoneLink.dstZoneTransform
                 player.darknessLogZone = Zone.byName(zoneLink.dstZoneName)
             elif player.monster:
                 player.monsterLogTransformInternal = zoneLink.dstZoneTransform
                 player.monsterLogZone = Zone.byName(zoneLink.dstZoneName)
             else:
                 player.logTransformInternal = zoneLink.dstZoneTransform
                 player.logZone = Zone.byName(zoneLink.dstZoneName)
             
             publicName,pbuffer,cbuffer,cvalues = ExtractPlayer(player.publicName,player.id,player.party.members[0].id,False)
             pbuffer = encodestring(dumps(pbuffer, 2))
             cbuffer = encodestring(dumps(cbuffer, 2))
             
             player.transfering = True
             aname = player.publicName
             if player.alliance:
                 aname = player.alliance.remoteLeaderName
             else:
                 print "Warning: Player %s has no alliance on zone trigger, could mess up alliances!!!!!"%player.publicName
             
             from mud.world.cserveravatar import AVATAR
             
             guildInfo = (player.guildName,player.guildInfo,player.guildMOTD,player.guildRank)
             d = AVATAR.mind.callRemote("transferPlayer", \
                 player.publicName,pbuffer,player.party.members[0].name, \
                 cbuffer,zoneName,cvalues,aname,guildInfo)
             d.addCallback(self.playerTransfered,[player.party.members[0].name],player)
             return
     
     
     zone = Zone.byName(zoneName)
     
     
     if self.singlePlayer:
         self.closeZone(player.zone)
     
     allzi = []
     allzi.extend(self.liveZoneInstances)
     allzi.extend(self.waitingZoneInstances)
     
     zoptions = []
     
     if not self.singlePlayer:
         found = False
         for zi in allzi:
             if zi.zone == zone:
                 found = True
                 break
         if not found:
             allzi.append(self.startZoneProcess(zoneName))
     
     for zi in allzi:
         if zi.zone == zone:
             zo = ZoneOption()
             zo.zoneName = zoneName
             zo.zoneInstanceName = zi.name
             if zi.owningPlayer:
                 zo.owner = zi.owningPlayer.fantasyName
             else:
                 zo.owner = None  # dedicated
             zo.status = zi.status
             zoptions.append(zo)
     
     player.prepForZoneOut()
     player.zone.removePlayer(player)
     player.zone = None
     
     # can be a spell trigger too
     player.triggeredZoneLink = zoneLink
     player.triggeredZoneOptions = zoptions #store zone options (these need to expire)
     
     player.mind.callRemote("setZoneOptions",zoptions)
 def startZoneProcess(self,zoneName,dynamic=True):
     port = None
     for x in xrange(self.zoneStartPort,self.zoneStartPort+100):
         if x in self.usedZonePorts:
             continue
         port = x
         self.usedZonePorts.append(x)
         break
         
     if port == None:
         traceback.print_stack()
         print "AssertionError: no port assigned!"
         return
     
     zone = Zone.byName(zoneName)
     #hrm
     ip = self.zoneIP #see world server main.py
     simPassword = ""
     z = ZoneInstance(zone,ip,port,simPassword,None)
     z.world = self
     z.time = self.time
     z.dynamic = dynamic
     
     self.waitingZoneInstances.append(z)
     
     if self.frozen:
         cmd  =  r'..\bin\ZoneServer.exe'
         args = ""
     else:
         cmd  = sys.executable
         path = os.getcwd()
         args = r'%s/zoneserver.py'%path
     
     args += r' -dedicated'
     args += r' -serverport %i -zone %s -world %s -worldport %i'%(port,zoneName,self.multiName,self.worldPort)
     if dynamic:
         args += r' -dynamic'
     
     for arg in sys.argv:
         if arg.startswith("gameconfig="):
             args += " %s"%arg
     
     if sys.platform[:6] != "darwin":
         # Just don't provide cluster number via gameconfig until
         #  MoM uses gameconfig as well.
         args += r' -cluster=%i'%self.clusterNum
         s = 'start "%s" %s %s'%(os.getcwd(),cmd,args)
         s = os.path.normpath(s)
         print s
         os.system(s)
     
     else:
         if arg.startswith("-wx"):
             args += " -wx"
         
         cmd = sys.executable
         args = args.split(" ")
         args.insert(0,cmd)
         s = 'pythonw -c \'import os;os.spawnv(os.P_NOWAIT,"%s",[%s])\''%(cmd,','.join('"%s"'%arg for arg in args))
         print s
         os.system(s)
     
     return z
def GenRewardText(quest):
    itext = ""
    
    # Generate Lists
    gitems = []
    money = 0L
    experience = []
    cmf = []
    classes = []
    skills = []
    teleportZone = None
    respawns = []
    triggers = []
    res = []
    for action in quest.actions:
        gitems.extend([item.itemProto for item in action.giveItems])
        money += action.giveTin
        if action.giveXP:
            experience.append(action.giveXP)
        cmf.extend(list(action.factions))
        if action.trainClass:
            classes.append(action.trainClass)
        skills.extend(list(action.trainSkills))
        if action.teleportZone:
            teleportZone = action.teleportZone
        if action.respawn and action.respawn not in respawns:
            respawns.append(action.respawn)
        if action.triggerSpawnGroup and action.triggerSpawnGroup not in triggers:
            triggers.append(action.triggerSpawnGroup)
        if action.resurrect and action.resurrectXP not in res:
            res.append(action.resurrectXP)
    
    # Items Given
    if len(gitems):
        itext += "<br> *Items Given:* "
        for item in gitems:
            itext+="[[Item%s][%s]], "%(GetTWikiName(item.name),item.name)
            try:
                QUESTITEMS[2][item].append(quest)
            except KeyError:
                QUESTITEMS[2][item] = [quest]
        itext = itext[:-2]
    
    # Money
    if money:
        itext += "<br> *Money Given:* %s"%GenMoneyText(money)
    
    # Experience
    if len(experience):
        itext += "<br> *Experience:* %s"%', '.join(map(str,experience))
    
    # Factions
    if len(cmf):
        itext += "<br> *Faction:* %s"%', '.join('[[Faction%s][%s]] (%i)'%(GetTWikiName(f.faction.name),f.faction.name,f.amount) for f in cmf)
        
        for f in cmf:
            questFaction = QUESTFACTIONS[f.faction.name]  
            if 0 < f.amount:
                questFaction.raises.add(quest.name)
            else:
                questFaction.lowers.add(quest.name)
            
    
    # Train in class
    if len(classes):
        itext += "<br> *Train Class:* %s"%', '.join('[[Class%s][%s]]'%(GetTWikiName(cl),cl) for cl in classes)
    
    # Train in skill
    if len(skills):
        itext += "<br> *Train Skill:* %s"%', '.join('[[Skill%s][%s]]'%(GetTWikiName(sk.skill),sk.skill) for sk in skills)
    
    # Teleport
    if teleportZone:
        z = Zone.byName(teleportZone)
        itext += "<br> *Teleport:* [[Zone%s][%s]]"%(GetTWikiName(z.niceName),z.niceName)
    
    """
    respawn = ForeignKey('Spawn',default=None)
    triggerSpawnGroup = StringCol(default="") #todo, move spawnpoints to database, somehow
    
    resurrect = BoolCol(default = False)
    resurrectXP = FloatCol(default = 0)
    """
    
    # Respawns
    if len(respawns):
        itext += "<br> *Respawn:* %s"%', '.join('[[Spawn%s][%s]]'%(GetTWikiName(s.name),s.name) for s in respawns)
    
    # Triggers
    if len(triggers):
        itext += "<br> *Trigger Spawn Group:* %s"%', '.join(triggers)
    
    # Resurrect
    if len(res):
        itext += "<br> *Resurrection:* %s"%', '.join('%i%%'%int(r*100.0) for r in res)
    
    return itext