Fireworks from NPCs

Find the proper support area, Saga-Version.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Airin
Posts: 81
Joined: Wed Sep 23, 2009 6:53 pm

Fireworks from NPCs

Post 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?
a.k.a TrueDecko
CUSTOM ITEMS WITHOUT ANY COPYRIGHT VIOLATION - APPROVED BY NCZ0ft - PRESS ON IMAGE TO REACH TUTORIAL!
Image
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Fireworks from NPCs

Post 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.
Last edited by jurchiks on Sun Dec 11, 2011 4:52 pm, edited 1 time in total.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
User avatar
Szponiasty
Advanced User
Advanced User
Posts: 557
Joined: Mon Apr 21, 2008 1:31 pm
Location: Eastern Poland

Re: Fireworks from NPCs

Post 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()    {}} 
And in the next chronicle they went into space, fighting the evil empire... In a galaxy far, far away xD
Airin
Posts: 81
Joined: Wed Sep 23, 2009 6:53 pm

Re: Fireworks from NPCs

Post 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.
a.k.a TrueDecko
CUSTOM ITEMS WITHOUT ANY COPYRIGHT VIOLATION - APPROVED BY NCZ0ft - PRESS ON IMAGE TO REACH TUTORIAL!
Image
Airin
Posts: 81
Joined: Wed Sep 23, 2009 6:53 pm

Re: Fireworks from NPCs

Post by Airin »

Seems that there is still no fireworks. Let's blame timers.
Suggestions?
a.k.a TrueDecko
CUSTOM ITEMS WITHOUT ANY COPYRIGHT VIOLATION - APPROVED BY NCZ0ft - PRESS ON IMAGE TO REACH TUTORIAL!
Image
User avatar
tukune
Posts: 533
Joined: Sun Mar 29, 2009 2:35 pm
Location: Japan

Re: Fireworks from NPCs

Post by tukune »

SantaHelper.java.error.log
User avatar
Szponiasty
Advanced User
Advanced User
Posts: 557
Joined: Mon Apr 21, 2008 1:31 pm
Location: Eastern Poland

Re: Fireworks from NPCs

Post by Szponiasty »

Code: Select all

public class SantaHelper extends Quest implements Runnable
WTF?

See how other quest/event scripts are constructed :P
And in the next chronicle they went into space, fighting the evil empire... In a galaxy far, far away xD
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Fireworks from NPCs

Post by jurchiks »

he's got INTERLUDE, no java quest engine there...
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Airin
Posts: 81
Joined: Wed Sep 23, 2009 6:53 pm

Re: Fireworks from NPCs

Post by Airin »

tukune wrote:SantaHelper.java.error.log
Script loads succesfully. Otherwise, it do not works.
a.k.a TrueDecko
CUSTOM ITEMS WITHOUT ANY COPYRIGHT VIOLATION - APPROVED BY NCZ0ft - PRESS ON IMAGE TO REACH TUTORIAL!
Image
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Fireworks from NPCs

Post by jurchiks »

did you add the debug line where I told you to? does it log?
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
User avatar
Szponiasty
Advanced User
Advanced User
Posts: 557
Joined: Mon Apr 21, 2008 1:31 pm
Location: Eastern Poland

Re: Fireworks from NPCs

Post 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.
And in the next chronicle they went into space, fighting the evil empire... In a galaxy far, far away xD
Post Reply