The net.sf.l2j.gameserver.model.quest package library is a part of the L2J server project which is a free and open-source, emulator of the popular MMORPG Lineage 2. This package contains a set of classes and interfaces that allow developers to create custom quests for their Lineage 2 servers.
One of the classes in this package is State. State is used to represent a specific state of a quest or a task within a quest. The addKillId method of State allows developers to register a specific NPC or monster kill as a requirement for completing a task or progressing through a quest.
Here is an example of using addKillId in a custom quest:
from net.sf.l2j.gameserver.model.quest import State from net.sf.l2j.gameserver.model.quest import QuestState from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest
# Define a custom quest class MyQuest(JQuest): def __init__(self, id, name, descr): JQuest.__init__(self, id, name, descr) self.addStartNpc(123) # Add an NPC as the quest giver self.addKillId(456) # Register a monster kill as a quest requirement
def onKill(self, npc, player, isPet): qs = player.getQuestState(self.getName()) if qs and qs.getState() == State.STARTED: if npc.getNpcId() == 456: qs.set("progress", str(int(qs.get("progress", "0")) + 1)) if int(qs.get("progress", "0")) >= 10: # Complete the quest if the player has killed 10 monsters qs.setState(State.COMPLETED) qs.playSound("ItemSound.quest_finish")
In this example, we define a custom quest called "MyQuest". In the __init__ method, we use the addStartNpc method to register an NPC as the quest giver and the addKillId method to register a monster as a quest requirement.
In the onKill method, we check if the player has started the quest and is on the right state. If the NPC killed is the required monster, we increment the "progress" value in the player's quest state. If the progress is 10 or greater, we set the quest state as completed and play a sound to notify the player.
Overall, the net.sf.l2j.gameserver.model.quest package library provides a powerful set of tools for developers to create custom quests and tasks in their Lineage 2 servers.
Python State.addKillId - 55 examples found. These are the top rated real world Python examples of net.sf.l2j.gameserver.model.quest.State.addKillId extracted from open source projects. You can rate examples to help us improve the quality of examples.