Page 1 of 1

Fireworks from NPCs

Posted: Sun Dec 11, 2011 4:04 pm
by Airin
Hello.
I want to make custom event for mine Interlude server. I already done NPCs running and shouting, but think I want is to make that running npcs shot fireworks each 5 minutes.
Currently mine code looks like this:

Code: Select all

 package net.sf.l2j.gameserver.ai.special; // yes i made this to be loaded from core. i am not familiar to py import net.sf.l2j.gameserver.model.quest.Quest;import net.sf.l2j.gameserver.model.L2Skill;import net.sf.l2j.gameserver.datatables.SkillTable;import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; /* * @author Airin */ public class SantaHelper extends Quest implements Runnable{    private static final int SANTA_HELPER = 56;    private static final int SANTA_HELPER2 = 57;     public SantaHelper(int questId, String name, String descr)    {        super(questId, name, descr);         addEventId(SANTA_HELPER, Quest.QuestEventType.ON_SPAWN);        addEventId(SANTA_HELPER2, Quest.QuestEventType.ON_SPAWN);    }        @Override    public String onSpawn(L2NpcInstance npc)    {        if(npc.getNpcId() == SANTA_HELPER || npc.getNpcId() == SANTA_HELPER2)        {            startQuestTimer("Firework", 300000, npc, null);        }        return super.onSpawn(npc);    }    @Override    public String onAdvEvent(String event, L2NpcInstance npc, L2PcInstance player)    {        if(event == "Firework")        {            L2Skill skill = SkillTable.getInstance().getInfo(2024, 1);            if(skill != null)            {                npc.doCast(skill);            }            startQuestTimer("Firework", 300000, npc, null);        }        return super.onAdvEvent(event, npc, player);    }     @Override    public void run()    {}} 
Server loads script succesfully but fireworks is not working.

Can somebody help me a bit with this?

Re: Fireworks from NPCs

Posted: Sun Dec 11, 2011 4:50 pm
by jurchiks
300000 ms = 5 minutes. Maybe that's your problem?
You could also add a debug message to the onSpawn method to see if the code is actually executed.

Re: Fireworks from NPCs

Posted: Sun Dec 11, 2011 4:51 pm
by Szponiasty
Try that

Code: Select all

  package net.sf.l2j.gameserver.ai.special; // yes i made this to be loaded from core. i am not familiar to py import net.sf.l2j.gameserver.model.quest.Quest;import net.sf.l2j.gameserver.model.L2Skill;import net.sf.l2j.gameserver.datatables.SkillTable;import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; /* * @author Airin */ public class SantaHelper extends Quest implements Runnable{    private static final int SANTA_HELPER = 56;    private static final int SANTA_HELPER2 = 57;     public SantaHelper(int questId, String name, String descr)    {        super(questId, name, descr);         addEventId(SANTA_HELPER, Quest.QuestEventType.ON_SPAWN);        addEventId(SANTA_HELPER2, Quest.QuestEventType.ON_SPAWN);    }        @Override    public String onSpawn(L2NpcInstance npc)    {        if(npc.getNpcId() == SANTA_HELPER || npc.getNpcId() == SANTA_HELPER2)        {            startQuestTimer("Firework", 300000, npc, null);        }        return super.onSpawn(npc);    }    @Override    public String onAdvEvent(String event, L2NpcInstance npc, L2PcInstance player)    {        if(event == "Firework")        {            final MagicSkillUse fireworkEffect = new MagicSkillUse(npc, npc, 2024, 1, 550, 50);            npc.broadcastPacket(fireworkEffect);            startQuestTimer("Firework", 300000, npc, null);        }        return super.onAdvEvent(event, npc, player);    }     @Override    public void run()    {}} 

Re: Fireworks from NPCs

Posted: Sun Dec 11, 2011 5:23 pm
by Airin
Szponiasty, thank you. I will try this.
By the way I am not sure about that timers, maybe they are not working. Maybe someone have better idea for handling that?

I planned fireworks needs to be launched each 5mins.

Re: Fireworks from NPCs

Posted: Sun Dec 11, 2011 6:04 pm
by Airin
Seems that there is still no fireworks. Let's blame timers.
Suggestions?

Re: Fireworks from NPCs

Posted: Mon Dec 12, 2011 7:13 am
by tukune
SantaHelper.java.error.log

Re: Fireworks from NPCs

Posted: Mon Dec 12, 2011 7:45 am
by Szponiasty

Code: Select all

public class SantaHelper extends Quest implements Runnable
WTF?

See how other quest/event scripts are constructed :P

Re: Fireworks from NPCs

Posted: Mon Dec 12, 2011 9:20 am
by jurchiks
he's got INTERLUDE, no java quest engine there...

Re: Fireworks from NPCs

Posted: Mon Dec 12, 2011 1:28 pm
by Airin
tukune wrote:SantaHelper.java.error.log
Script loads succesfully. Otherwise, it do not works.

Re: Fireworks from NPCs

Posted: Mon Dec 12, 2011 6:00 pm
by jurchiks
did you add the debug line where I told you to? does it log?

Re: Fireworks from NPCs

Posted: Mon Dec 12, 2011 10:55 pm
by Szponiasty
jurchiks wrote:he's got INTERLUDE, no java quest engine there...
Then I have no idea. Dont remember how it was done back in those days :( Anyway if its as implementation of Runnable then probably he need to add it as new thread to thread pool somewhere (in constructor?!) i guess. Mby that will help.