Ejemplo n.º 1
0
 def onAdvEvent(self, event, npc, player):
     st = player.getQuestState(qn)
     if not st:
         st = self.newQuestState(player)
     level = int(event[3:])
     KamaInfo = KAMALOKA[level]
     if not KamaInfo[9]:
         player.sendPacket(
             SystemMessage.sendString(
                 "This Kamaloka has been disabled by an Admin"))
         return
     party = player.getParty()
     if party:
         partyLeader = st.getPlayer().getParty().getLeader()
         if player != partyLeader:
             player.sendPacket(
                 SystemMessage(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER))
             return
     if player.getInstanceId() != 0:
         player.sendPacket(
             SystemMessage(SystemMessageId.
                           ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER))
         return
     instanceId = enterInstance(self, player, KamaInfo, level)
     if not instanceId:
         return
     if instanceId == 0:
         return
     return
Ejemplo n.º 2
0
def checkCondition(player):
    party = player.getParty()
    if not party:
        player.sendPacket(
            SystemMessage(SystemMessageId.NOT_IN_PARTY_CANT_ENTER))
        return False
    else:
        st = player.getQuestState(qn)
        partyLeader = st.getPlayer().getParty().getLeader()
        if player != partyLeader:
            player.sendPacket(
                SystemMessage(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER))
            return
        for partyMember in party.getPartyMembers().toArray():
            if not partyMember.isInsideRadius(player, 500, True, True):
                sm = SystemMessage(
                    SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED)
                sm.addPcName(partyMember)
                player.sendPacket(sm)
                return False
            if not partyMember.getLevel() >= 78:
                sm = SystemMessage(
                    SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT)
                sm.addPcName(partyMember)
                player.sendPacket(sm)
                partyMember.sendPacket(sm)
                return False
    return True
Ejemplo n.º 3
0
def checkCondition(player, KamaInfo):
    currentTime = System.currentTimeMillis() / 1000
    party = player.getParty()
    if not party:
        player.sendPacket(
            SystemMessage(SystemMessageId.NOT_IN_PARTY_CANT_ENTER))
        return False
    # Check size of the party, max 6 for entering Kamaloka Hall of Abyss, 9 for Labyrinth
    if party and party.getMemberCount() > KamaInfo[5]:
        player.sendPacket(
            SystemMessage(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER))
        return False
    for partyMember in party.getPartyMembers().toArray():
        if partyMember.getLevel() < KamaInfo[3] or partyMember.getLevel(
        ) > KamaInfo[4]:
            sm = SystemMessage(
                SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT)
            sm.addPcName(partyMember)
            player.sendPacket(sm)
            partyMember.sendPacket(sm)
            return False
        st = partyMember.getQuestState(qn)
        if st:
            LastEntry = st.getInt("LastEntry")
            if currentTime < LastEntry + KamaInfo[1]:
                sm = SystemMessage(SystemMessageId.NO_RE_ENTER_TIME_FOR_C1)
                sm.addPcName(partyMember)
                player.sendPacket(sm)
                partyMember.sendPacket(sm)
                return False
    return True
Ejemplo n.º 4
0
 def onTalk (self,npc,player) :
  htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>"
  st = player.getQuestState(qn)
  if not st : return htmltext
  clan = player.getClan()
  npcId = npc.getNpcId()
  if player.getClan() == None or player.isClanLeader() == 0 :
     st.exitQuest(1)
     htmltext = "30868-0a.htm"
  elif player.getClan().getLevel() < 5 :
     st.exitQuest(1)
     htmltext =  "30868-0b.htm"
  else :
     cond = st.getInt("cond")
     raid = st.getInt("raid")
     id = st.getState()
     if id == State.CREATED and cond == 0 :
        htmltext =  "30868-0c.htm"
     elif id == State.STARTED and cond == 1 and raid in REWARDS_LIST.keys() :
        npc,item,min,max=REWARDS_LIST[raid]
        count = st.getQuestItemsCount(item)
        CLAN_POINTS_REWARD = Rnd.get(min, max)
        if not count :
           htmltext = "30868-"+str(raid)+"a.htm"
        elif count == 1 :
           htmltext = "30868-"+str(raid)+"b.htm"
           st.takeItems(item,1)
           clan.setReputationScore(clan.getReputationScore()+CLAN_POINTS_REWARD,True)
           player.sendPacket(SystemMessage(1777).addNumber(CLAN_POINTS_REWARD))
           clan.broadcastToOnlineMembers(PledgeShowInfoUpdate(clan))
  return htmltext
Ejemplo n.º 5
0
 def onTalk (self,npc,player) :
  htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>"
  st = player.getQuestState(qn)
  if not st : return htmltext
  clan = player.getClan()
  npcId = npc.getNpcId()
  if player.getClan() == None or player.isClanLeader() == 0 :
     st.exitQuest(1)
     htmltext = "31331-0.htm"
  elif player.getClan().getLevel() < 5 :
     st.exitQuest(1)
     htmltext =  "31331-0.htm"
  else :
     cond = st.getInt("cond")
     id = st.getState()
     if id == State.CREATED and cond == 0 :
        htmltext =  "31331-1.htm"
     elif id == State.STARTED and cond == 1 :
        count = st.getQuestItemsCount(Claw)
        if not count :
           htmltext = "31331-4.htm"
        elif count >= 1 :
           htmltext = "31331-7.htm" # custom html
           st.takeItems(Claw,-1)
           reward = int(CLAN_POINTS_REWARD * count)
           clan.setReputationScore(clan.getReputationScore()+reward,True)
           player.sendPacket(SystemMessage(1777).addNumber(reward))
           clan.broadcastToOnlineMembers(PledgeShowInfoUpdate(clan))
  return htmltext
Ejemplo n.º 6
0
def enterInstance(self, player, template, teleto):
    instanceId = 0
    if not checkCondition(player):
        return 0
    party = player.getParty()
    # Check for existing instances of party members
    for partyMember in party.getPartyMembers().toArray():
        if partyMember.getInstanceId() != 0:
            sm = SystemMessage(
                SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED)
            sm.addPcName(partyMember)
            player.sendPacket(sm)
            return 0
    instanceId = InstanceManager.getInstance().createDynamicInstance(template)
    world = PyObject()
    world.instanceId = instanceId
    world.instanceFinished = False
    world.guardsSpawned = False
    world.status = 0
    self.worlds[instanceId] = world
    self.world_ids.append(instanceId)
    spawnKeyMaster(self, world)
    # Teleports player
    teleto.instanceId = instanceId
    for partyMember in party.getPartyMembers().toArray():
        st = partyMember.getQuestState(qn)
        if not st:
            self.newQuestState(partyMember)
        teleportplayer(self, partyMember, teleto)
    return instanceId
Ejemplo n.º 7
0
def EvolvePet(player,item,striderControlItem) :
   con = L2DatabaseFactory.getInstance().getConnection()
   statement = con.prepareStatement("UPDATE items SET item_id =? WHERE object_id=? AND owner_id=?")
   statement.setInt(1, striderControlItem)
   statement.setInt(2, item.getObjectId())
   statement.setInt(3, player.getObjectId())
   statement.execute()
   statement.close()
   con.close()
   sm1 = SystemMessage(SystemMessageId.S2_S1_DISAPPEARED)
   sm1.addItemName(item.getItemId())
   sm1.addNumber(1)
   sm2 = SystemMessage(SystemMessageId.YOU_PICKED_UP_A_S1_S2)
   sm2.addNumber(item.getEnchantLevel())
   sm2.addItemName(striderControlItem)
   player.sendPacket(sm1)
   player.sendPacket(sm2)
   player.sendPacket(ItemList(player, False))
   return
Ejemplo n.º 8
0
def checkCondition(player):
    if not player.getLevel() >= 78:
        sm = SystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT)
        sm.addPcName(player)
        player.sendPacket(sm)
        return False
    party = player.getParty()
    if not party:
        player.sendPacket(SystemMessage(SystemMessageId.NOT_IN_PARTY_CANT_ENTER))
        return False
    if party and party.getMemberCount() > 2:
        player.sendPacket(SystemMessage(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER))
        return False
    st = player.getQuestState(qn)
    partyLeader = st.getPlayer().getParty().getLeader()
    if player != partyLeader:
        player.sendPacket(SystemMessage(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER))
        return False
    return True
Ejemplo n.º 9
0
 def giveItem(self, player, itemId, count):
     item = player.getInventory().addItem("Quest", itemId, count, player,
                                          None)
     iu = InventoryUpdate()
     iu.addItem(item)
     player.sendPacket(iu)
     sm = SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2)
     sm.addItemName(item)
     sm.addNumber(1)
     player.sendPacket(sm)
     return item
Ejemplo n.º 10
0
def checkDistance(player):
    isTooFar = False
    party = player.getParty()
    if party:
        for partyMember in party.getPartyMembers().toArray():
            if not partyMember.isInsideRadius(player, MAX_DISTANCE, True,
                                              True):
                isTooFar = True
                break
    if isTooFar:
        sm = SystemMessage(
            SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED)
        sm.addPcName(partyMember)
        player.sendPacket(sm)
    return isTooFar
Ejemplo n.º 11
0
 def onSkillSee(self, npc, caster, skill, targets, isPet):
     if HellboundManager.getInstance().getHellboundLevel() >= 7:
         skillId = skill.getId()
         if skillId != 2359:
             return
         if not npc in targets:
             return
         percent = npc.getStatus().getCurrentHp() / npc.getMaxHp() * 100
         if percent <= 10:
             npc.setMagicBottled(True, percent)
         else:
             npc.setQuestDropable(False)
             caster.sendPacket(
                 SystemMessage(SystemMessageId.NOTHING_HAPPENED))
             return
     return
Ejemplo n.º 12
0
    def onTalk (self,npc,player):
        npcId = npc.getNpcId()
        if npcId == YIYEN :
            tele = PyObject()
            tele.x = 146534
            tele.y = 180464
            tele.z = -6117
            instanceId = enterInstance(self, player, "DarkCloudMansion.xml", tele)
            if not instanceId:
                return
            if instanceId == 0:
                return
        elif npcId == SOTruth :
            if npc.getInstanceId() == 0:
                return
            world = self.worlds[npc.getInstanceId()]
            item = player.getInventory().addItem("Quest", CC, 1, player, None)
            iu = InventoryUpdate()
            iu.addItem(item)
            player.sendPacket(iu)
            sm = SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2)
            sm.addItemName(item)
            sm.addNumber(1)
            player.sendPacket(sm)

            tele = PyObject()
            tele.x = 139968
            tele.y = 150367
            tele.z = -3111
            exitInstance(player,tele)
            if debug: print "DarkCloudMansion - id"+str(player.getObjectId())+" rewarded and gone out of instance"

            # Check if the instance is empty, as it should be destroyed directly if yes according to retail info.
            playerList = InstanceManager.getInstance().getInstance(world.instanceId).getPlayers().toArray()
            playerCount = len(playerList)
            if playerCount == 0:
                del self.worlds[npc.getInstanceId()]
                self.world_ids.remove(npc.getInstanceId())
                InstanceManager.getInstance().destroyInstance(npc.getInstanceId())
        return
Ejemplo n.º 13
0
def enterInstance(self, player, KamaInfo, level):
    instanceId = 0
    template = KamaInfo[0]
    reuse = KamaInfo[1]
    if checkDistance(player):
        return 0
    if not checkCondition(player, KamaInfo):
        return 0
    party = player.getParty()
    # Check for existing instances of party members
    for partyMember in party.getPartyMembers().toArray():
        if partyMember.getInstanceId() != 0:
            sm = SystemMessage(
                SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED)
            sm.addPcName(partyMember)
            player.sendPacket(sm)
            return 0
    # New instance
    instanceId = InstanceManager.getInstance().createDynamicInstance(template)
    world = PyObject()
    world.instanceId = instanceId
    self.worlds[instanceId] = world
    self.world_ids.append(instanceId)
    if level in [29, 39, 49, 59, 69, 78, 81]:
        world.level = level
        startFirstRoom(self, world)
    if debug:
        print "Kamaloka: started " + template + " Instance: " + str(
            instanceId) + " created by player: " + str(player.getName())
    # Teleport players
    for partyMember in party.getPartyMembers().toArray():
        partyMember.stopAllEffectsExceptThoseThatLastThroughDeath()
        partyMember.clearSouls()
        partyMember.clearCharges()
        teleportplayer(self, partyMember, KamaInfo, instanceId)
    return instanceId