Jump to content

Question

Posted

Hi,

I am using L2jserver files. Latest revision ( Beta ). DP:10079 L2J:6317

This is the script im trying to make it work.
GS dont show any errors.. And then i kill barakiel it wont give me nobless.
Yes i killed it with subclass and writen path to scripts.cfg

Help please. Thanks in advice.

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package custom.Nobless;

import com.l2jserver.gameserver.model.L2CommandChannel;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;

/**
 * 
 * @author mochitto
 *
 */
public final class Noblesse extends Quest
{
	private static final String QN = "Noblesse";
	private static final int BARAKIEL = 25325;
	private static final int NOBLESS_TIARA = 7694;
	private static final String[] PARTS = 
	{
		"Q00241_PossessorOfAPreciousSoul_1",
		"Q00242_PossessorOfAPreciousSoul_2",
		"Q00246_PossessorOfAPreciousSoul_3",
		"Q00247_PossessorOfAPreciousSoul_4"
	};

	@Override
	public final String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
	{
		if( getId() != BARAKIEL )
			return null;
		L2CommandChannel cmd = null;
		
		L2Party party = player.getParty();
		
		if (party != null)
			cmd = player.getParty().getCommandChannel();
		
		if (cmd != null)
		{
			for (L2PcInstance partyMember : cmd.getMembers())
			{
				if(!partyMember.isNoble() && partyMember.isSubClassActive())
				{					
					for(String q : PARTS)
					{
						QuestState st = partyMember.getQuestState(q);
						if (st != null)
						{
							st.setState(State.COMPLETED);
							st.exitQuest(false);
						}
					}					
					partyMember.setNoble(true);
					partyMember.sendMessage("Congratulations. You are now Noblesse.");
					partyMember.addItem("Custom nobless", NOBLESS_TIARA, 1, null, true);
					_log.info("Noblesse: Player "+partyMember+" get nobless.");
				}
			}
		}
		else if (party != null)
		{
			for (L2PcInstance partyMember : party.getMembers())
			{
				if(!partyMember.isNoble() && partyMember.isSubClassActive())
				{					
					for(String q : PARTS)
					{
						QuestState st = partyMember.getQuestState(q);
						if (st != null)
						{
							st.setState(State.COMPLETED);
							st.exitQuest(false);
						}
					}					
					partyMember.setNoble(true);
					partyMember.sendMessage("Congratulations. You are now Noblesse.");
					partyMember.addItem("Custom nobless", NOBLESS_TIARA, 1, null, true);
					_log.info("Noblesse: Player "+partyMember+" get nobless.");
				}
			}
		}
		else
		{
			if(!player.isNoble() && player.isSubClassActive())
			{					
				for(String q : PARTS)
				{
					QuestState st = player.getQuestState(q);
					if (st != null)
					{
						st.setState(State.COMPLETED);
						st.exitQuest(false);
					}
				}					
				player.setNoble(true);
				player.sendMessage("Congratulations. You are now Noblesse.");
				player.addItem("Custom nobless", NOBLESS_TIARA, 1, null, true);
				_log.info("Noblesse: Player "+player+" get nobless.");
			}
		}
		
		return super.onKill(npc, player, isPet);
	}
	
	public Noblesse(int questId, String name, String descr)
	{
		super(questId, name, descr);
		addKillId(BARAKIEL);
	}
	
	public static void main(String[] args)
	{
		new Noblesse(-1, QN, "custom");
	}
}


6 answers to this question

Recommended Posts

  • 0
Posted

Try to debug it, check if constructor is being used, after that if onKill(L2Npc,L2PcInstance,boolean) is run after death of barakiel. I think player that made last kill on barakiel, needs to have this "Nobless" quest with ID -1 already started(or in l2jserver this quest will be somehow global, i am not sure).

  • 0
Posted

Try to debug it, check if constructor is being used, after that if onKill(L2Npc,L2PcInstance,boolean) is run after death of barakiel. I think player that made last kill on barakiel, needs to have this "Nobless" quest with ID -1 already started(or in l2jserver this quest will be somehow global, i am not sure).

How can i check that ? GS shows nothing.. What u mean , i have to check if script even reacting to barakiel killing or not. This was my first idea,but since i dont know how to check that thing.. :]

  • 0
Posted

Try changing this line

 

-if(getId() != BARAKIEL)
+if(npc.getId() != BARAKIEL)

Thanks.. Working now.

L2j always changes core methods.. So stupid.

  • 0
Posted (edited)

If you want possible simples debugging, just put System.out.println("something blabla"); to part of the codes and watch gameserver console if it will appear.

Something a lot more advanced is debugging gameserver bat in real time. Add "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" after word "java " in StartGameServer.bat. Then you need to configurate Remote debugging option in your IDE, set host as localhost and port as 5005. Then when gameserver is running, you can start debugging it. All you have to do is set up break points, they will show you everything.

Edited by vampir
Guest
This topic is now closed to further replies.


×
×
  • Create New...