### Settings MonsterId = 12780 PolyId = 9 # orc MonsterName = "testmob" # this doesn't really matter, the game reads it out of the database ActionDelay = 10000 # 10 seconds ### Code print "importing " + str(MonsterId) + ": " + MonsterName, import sys from net.sf.l2j.gameserver.model.scriptedmonster import ScriptedMonsterList as MList from net.sf.l2j.gameserver.model.scriptedmonster import ScriptedMonsterFactory as JFactory from net.sf.l2j.gameserver.model import L2ScriptedMonsterInstance as JMonster from net.sf.l2j.gameserver.serverpackets import CreatureSay # these 2 are for the maintenance thread from net.sf.l2j.gameserver import ClientScheduler from java.lang import Runnable ### This is the monster code. All of the monster's events will be handled in here. class Monster (JMonster): # Constructor - anything to be done at mob creation (NOT mob spawn) should be done here. # In this case, I'm setting the character model to something other than the default. def __init__(self, objectId, template): JMonster.__init__(self, objectId, template) self.getPoly().setPolyInfo("npc", str(PolyId)) # Do this whenever the monster takes damage def addDamage(self, attacker, damage): msg = CreatureSay(self.getObjectId(), 2, self.getName(), "oof! oww! " + str(damage) + " damage.") self.broadcastPacket(msg) self.addDamageHate(attacker, damage, damage) # this calls the default behavior # Do this when the monster spawns def OnSpawn(self): msg = CreatureSay(self.getObjectId(), 2, self.getName(), "I appear!") self.broadcastPacket(msg) # call MonsterAction.run in ActionDelay milliseconds (useful for timed events) ClientScheduler.scheduleEvent(MonsterAction(self), ActionDelay) self.super__OnSpawn() # Do this when the monster dies def doDie(self, killer): msg = CreatureSay(self.getObjectId(), 2, self.getName(), "Woe is me!") self.broadcastPacket(msg) self.super__doDie(killer) ### Event thread. Every ActionDelay seconds execute this class MonsterAction (Runnable): def __init__( self, monster ): self.monster = monster # run is the method which is actually called def run(self): msg = CreatureSay(self.monster.getObjectId(), 2, self.monster.getName(), "10 seconds have elapsed.") self.monster.broadcastPacket(msg) # schedule the event again, so it repeats ClientScheduler.scheduleEvent(self, ActionDelay) ### Everything below this line is needed to register the monster with the game. Don't touch! class MonsterFactory (JFactory): def getMonster(self,objectId, template): return Monster(objectId, template) MList.getInstance().registerMonster(MonsterId, MonsterFactory())