2
0
Эх сурвалжийг харах

Starter Quests as per C3 (Thanks Kerberos)

yellowperil 17 жил өмнө
parent
commit
bea98bc08c

+ 14 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/clientpackets/CharacterCreate.java

@@ -25,11 +25,14 @@ import net.sf.l2j.gameserver.datatables.CharTemplateTable;
 import net.sf.l2j.gameserver.datatables.SkillTable;
 import net.sf.l2j.gameserver.datatables.SkillTreeTable;
 import net.sf.l2j.gameserver.idfactory.IdFactory;
+import net.sf.l2j.gameserver.instancemanager.QuestManager;
 import net.sf.l2j.gameserver.model.L2ItemInstance;
 import net.sf.l2j.gameserver.model.L2ShortCut;
 import net.sf.l2j.gameserver.model.L2SkillLearn;
 import net.sf.l2j.gameserver.model.L2World;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.quest.Quest;
+import net.sf.l2j.gameserver.model.quest.QuestState;
 import net.sf.l2j.gameserver.network.L2GameClient;
 import net.sf.l2j.gameserver.serverpackets.CharCreateFail;
 import net.sf.l2j.gameserver.serverpackets.CharCreateOk;
@@ -214,7 +217,7 @@ public final class CharacterCreate extends L2GameClientPacket
 			if (Config.DEBUG)
 				_log.fine("adding starter skill:" + startSkills[i].getId()+ " / "+ startSkills[i].getLevel());
 		}
-
+		startTutorialQuest(newChar);
 		L2GameClient.saveCharToDisk(newChar);
 		newChar.deleteMe(); // release the world of this character and it's inventory
 
@@ -226,6 +229,16 @@ public final class CharacterCreate extends L2GameClientPacket
         if (Config.DEBUG) _log.fine("Character init end");
 	}
 
+	public void startTutorialQuest(L2PcInstance player)
+	{
+		QuestState qs = player.getQuestState("255_Tutorial");
+		Quest q = null;
+		if (qs == null)
+			q = QuestManager.getInstance().getQuest("255_Tutorial");
+		if (q != null)
+			q.newQuestState(player);
+	}
+
 	/* (non-Javadoc)
 	 * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
 	 */

+ 9 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java

@@ -50,6 +50,7 @@ import net.sf.l2j.gameserver.model.entity.L2Event;
 import net.sf.l2j.gameserver.model.entity.Siege;
 import net.sf.l2j.gameserver.model.entity.TvTEvent;
 import net.sf.l2j.gameserver.model.quest.Quest;
+import net.sf.l2j.gameserver.model.quest.QuestState;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.serverpackets.Die;
 import net.sf.l2j.gameserver.serverpackets.EtcStatusUpdate;
@@ -126,6 +127,7 @@ public class EnterWorld extends L2GameClientPacket
         
         Quest.playerEnter(activeChar);
         activeChar.sendPacket(new QuestList());
+        loadTutorial(activeChar);
         
         // Register in flood protector
         FloodProtector.getInstance().registerNewPlayer(activeChar.getObjectId());
@@ -512,6 +514,13 @@ public class EnterWorld extends L2GameClientPacket
         }
     }
 
+    private void loadTutorial(L2PcInstance player)
+    {
+    	QuestState qs = player.getQuestState("255_Tutorial");
+    	if(qs != null)
+    		qs.getQuest().notifyEvent("UC", null, player);
+    }
+     
     /* (non-Javadoc)
      * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
      */

+ 46 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/clientpackets/RequestTutorialClientEvent.java

@@ -0,0 +1,46 @@
+/*
+ * 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 net.sf.l2j.gameserver.clientpackets;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.quest.QuestState;
+
+public class RequestTutorialClientEvent extends L2GameClientPacket
+{
+	private static final String _C__88_REQUESTTUTORIALCLIENTEVENT = "[C] 88 RequestTutorialClientEvent";
+	int eventId = 0;
+
+	protected void readImpl()
+	{
+		eventId = readD();
+	}
+
+	protected void runImpl()
+	{
+		L2PcInstance player = getClient().getActiveChar();
+
+		if(player == null)
+			return;
+
+		QuestState qs = player.getQuestState("255_Tutorial");
+		if(qs != null)
+			qs.getQuest().notifyEvent("CE" + eventId + "",null,player);
+	}
+
+	public String getType()
+	{
+		return _C__88_REQUESTTUTORIALCLIENTEVENT;
+	}
+}

+ 47 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/clientpackets/RequestTutorialLinkHtml.java

@@ -0,0 +1,47 @@
+/*
+ * 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 net.sf.l2j.gameserver.clientpackets;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.quest.QuestState;
+
+public class RequestTutorialLinkHtml extends L2GameClientPacket
+{
+	private static final String _C__85_REQUESTTUTORIALLINKHTML = "[C] 85 RequestTutorialLinkHtml";
+	String _bypass;
+
+	protected void readImpl()
+	{
+		_bypass = readS();
+	}
+
+	@Override
+	protected void runImpl()
+	{ 
+		L2PcInstance player = getClient().getActiveChar();
+		if(player == null)
+			return;
+
+		QuestState qs = player.getQuestState("255_Tutorial");
+		if(qs != null)
+			qs.getQuest().notifyEvent(_bypass, null, player);
+	}
+
+	@Override
+	public String getType()
+	{
+		return _C__85_REQUESTTUTORIALLINKHTML;
+	}
+} 

+ 44 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/clientpackets/RequestTutorialPassCmdToServer.java

@@ -0,0 +1,44 @@
+/*
+ * 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 net.sf.l2j.gameserver.clientpackets;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.quest.QuestState;
+
+public class RequestTutorialPassCmdToServer extends L2GameClientPacket
+{
+	String _bypass = null;
+
+	protected void readImpl()
+	{
+		_bypass = readS();
+	} 
+	protected void runImpl()
+	{
+		L2PcInstance player = getClient().getActiveChar();
+
+		if(player == null)
+			return;
+
+		QuestState qs = player.getQuestState("255_Tutorial");
+		if(qs != null)
+			qs.getQuest().notifyEvent(_bypass, null, player);
+       	}
+
+	public String getType()
+	{
+		return "[C] 86 RequestTutorialPassCmdToServer";
+	}
+}

+ 46 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/clientpackets/RequestTutorialQuestionMark.java

@@ -0,0 +1,46 @@
+/*
+ * 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 net.sf.l2j.gameserver.clientpackets;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.quest.QuestState;
+
+public class RequestTutorialQuestionMark extends L2GameClientPacket
+{
+	//     private static Logger _log = Logger.getLogger(RequestTutorialQuestionMark.class.getName());
+	int _number = 0;
+
+	protected void readImpl()
+	{
+		_number = readD();
+	}
+	protected void runImpl()
+	{
+		L2PcInstance player = getClient().getActiveChar();
+
+		if(player == null)
+			return;
+
+		QuestState qs = player.getQuestState("255_Tutorial");
+		if(qs != null)
+			qs.getQuest().notifyEvent("QM" + _number + "",null,player);
+	}
+
+	@Override
+	public String getType()
+	{
+		return "[C] 87 RequestTutorialQuestionMark";
+	}
+}

+ 7 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/L2Object.java

@@ -22,6 +22,7 @@ import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.actor.knownlist.ObjectKnownList;
 import net.sf.l2j.gameserver.model.actor.poly.ObjectPoly;
 import net.sf.l2j.gameserver.model.actor.position.ObjectPosition;
+import net.sf.l2j.gameserver.model.quest.QuestState;
 import net.sf.l2j.gameserver.network.L2GameClient;
 import net.sf.l2j.gameserver.serverpackets.ActionFailed;
 import net.sf.l2j.gameserver.serverpackets.GetItem;
@@ -200,6 +201,12 @@ public abstract class L2Object
         		MercTicketManager.getInstance().removeTicket((L2ItemInstance)this);
         		ItemsOnGroundManager.getInstance().removeObject(this);
         	}
+        	if (itemId == 57 || itemId == 6353)
+        	{
+        		QuestState qs = ((L2PcInstance) player).getQuestState("255_Tutorial");
+        		if(qs != null)
+        			qs.getQuest().notifyEvent("CE"+itemId+"",null,(L2PcInstance)player);
+        	}
         }
 
 

+ 7 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/actor/status/CharStatus.java

@@ -31,6 +31,7 @@ import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
 import net.sf.l2j.gameserver.model.actor.stat.CharStat;
 import net.sf.l2j.gameserver.model.entity.Duel;
+import net.sf.l2j.gameserver.model.quest.QuestState;
 import net.sf.l2j.gameserver.serverpackets.ActionFailed;
 import net.sf.l2j.gameserver.skills.Formulas;
 import net.sf.l2j.util.Rnd;
@@ -208,6 +209,12 @@ public class CharStatus
 
             // now reset currentHp to zero
             setCurrentHp(0);
+            if (getActiveChar() instanceof L2PcInstance)
+            {
+            	QuestState qs = ((L2PcInstance)getActiveChar()).getQuestState("255_Tutorial");
+            	if(qs != null)
+            		qs.getQuest().notifyEvent("CE30",null,((L2PcInstance)getActiveChar()));
+            }
         }
         else
         {

+ 39 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/quest/QuestState.java

@@ -20,10 +20,12 @@ import java.util.logging.Logger;
 import javolution.util.FastMap;
 import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.GameTimeController;
+import net.sf.l2j.gameserver.cache.HtmCache;
 import net.sf.l2j.gameserver.instancemanager.QuestManager;
 import net.sf.l2j.gameserver.model.L2Character;
 import net.sf.l2j.gameserver.model.L2DropData;
 import net.sf.l2j.gameserver.model.L2ItemInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.network.SystemMessageId;
@@ -33,6 +35,10 @@ import net.sf.l2j.gameserver.serverpackets.PlaySound;
 import net.sf.l2j.gameserver.serverpackets.QuestList;
 import net.sf.l2j.gameserver.serverpackets.StatusUpdate;
 import net.sf.l2j.gameserver.serverpackets.SystemMessage;
+import net.sf.l2j.gameserver.serverpackets.TutorialCloseHtml;
+import net.sf.l2j.gameserver.serverpackets.TutorialEnableClientEvent;
+import net.sf.l2j.gameserver.serverpackets.TutorialShowHtml;
+import net.sf.l2j.gameserver.serverpackets.TutorialShowQuestionMark;
 import net.sf.l2j.gameserver.skills.Stats;
 import net.sf.l2j.util.Rnd;
 
@@ -801,4 +807,37 @@ public final class QuestState
 
 		return this;
 	}
+
+	public void showQuestionMark(int number)
+	{
+		getPlayer().sendPacket(new TutorialShowQuestionMark(number));
+	}
+
+	public void playTutorialVoice(String voice)
+	{
+		getPlayer().sendPacket(new PlaySound(2, voice, 0, 0, getPlayer().getX(), getPlayer().getY(), getPlayer().getZ()));
+	}
+
+	public void showTutorialHTML(String html)
+	{
+		String text = HtmCache.getInstance().getHtm("data/scripts/quests/255_Tutorial/"+ html);
+		if(text == null || text.equalsIgnoreCase(""))
+			text = "<html><body>File data/scripts/quests/255_Tutorial/" + html + " not found or file is empty.</body></html>";
+		getPlayer().sendPacket(new TutorialShowHtml(text));
+	}
+
+	public void closeTutorialHtml()
+	{
+		getPlayer().sendPacket(new TutorialCloseHtml());
+	}
+
+	public void onTutorialClientEvent(int number)
+	{
+		getPlayer().sendPacket(new TutorialEnableClientEvent(number));
+	}
+
+	public void dropItem(L2MonsterInstance npc, L2PcInstance player, int itemId, int count)
+	{
+		npc.DropItem(player, itemId, count);
+	}
 }

+ 12 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/network/L2GamePacketHandler.java

@@ -413,6 +413,18 @@ public final class L2GamePacketHandler extends TCPHeaderHandler<L2GameClient> im
                     case 0x83:
                         msg = new RequestPrivateStoreBuy();
                         break;
+                    case 0x85:
+                        msg = new RequestTutorialLinkHtml();
+                        break;
+                    case 0x86:
+                       	msg = new RequestTutorialPassCmdToServer();
+                      	break;
+                    case 0x87:
+                        msg = new RequestTutorialQuestionMark();
+                        break;
+                    case 0x88:
+                       	msg = new RequestTutorialClientEvent();
+                      	break;
                     case 0x89:
                         msg = new RequestPetition();
                         break;

+ 32 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/serverpackets/TutorialCloseHtml.java

@@ -0,0 +1,32 @@
+/*
+ * 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 net.sf.l2j.gameserver.serverpackets;
+
+public class TutorialCloseHtml extends L2GameServerPacket
+{
+	private static final String _S__A9_TUTORIALCLOSEHTML = "[S] a9 TutorialCloseHtml";
+
+	@Override
+	protected void writeImpl()
+	{
+		writeC(0xa9);
+	}
+
+	@Override
+	public String getType()
+	{
+		return _S__A9_TUTORIALCLOSEHTML;
+	}
+} 

+ 40 - 0
L2_GameServer_T1/java/net/sf/l2j/gameserver/serverpackets/TutorialEnableClientEvent.java

@@ -0,0 +1,40 @@
+/*
+ * 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 net.sf.l2j.gameserver.serverpackets;
+
+public class TutorialEnableClientEvent extends L2GameServerPacket
+{
+	private static final String _S__A8_TUTORIALENABLECLIENTEVENT = "[S] a8 TutorialEnableClientEvent";
+	private int _eventId = 0;
+
+	public TutorialEnableClientEvent(int event)
+	{
+		_eventId = event;
+	}
+
+
+	@Override
+	protected void writeImpl()
+	{
+		writeC(0xa8);
+		writeD(_eventId);
+	}
+
+	@Override
+	public String getType()
+	{
+		return _S__A8_TUTORIALENABLECLIENTEVENT;
+	}
+} 

+ 2 - 2
L2_GameServer_T1/java/net/sf/l2j/gameserver/serverpackets/TutorialShowHtml.java

@@ -16,7 +16,7 @@ package net.sf.l2j.gameserver.serverpackets;
 
 public final class TutorialShowHtml extends L2GameServerPacket
 {
-	private static final String _S__A0_TUTORIALSHOWHTML = "[S] a6 TutorialShowHtml";
+	private static final String _S__A6_TUTORIALSHOWHTML = "[S] a6 TutorialShowHtml";
 	private String _html;
 
 	public TutorialShowHtml(String html)
@@ -40,7 +40,7 @@ public final class TutorialShowHtml extends L2GameServerPacket
 	@Override
 	public String getType()
 	{
-		return _S__A0_TUTORIALSHOWHTML;
+		return _S__A6_TUTORIALSHOWHTML;
 	}
 
 }

+ 5 - 5
L2_GameServer_T1/java/net/sf/l2j/gameserver/serverpackets/TutorialShowQuestionMark.java

@@ -16,12 +16,12 @@ package net.sf.l2j.gameserver.serverpackets;
 
 public final class TutorialShowQuestionMark extends L2GameServerPacket
 {
-	private static final String _S__A1_TUTORIALSHOWQUESTIONMARK = "[S] a7 TutorialShowQuestionMark";
-	private int _blink;
+	private static final String _S__A7_TUTORIALSHOWQUESTIONMARK = "[S] a7 TutorialShowQuestionMark";
+	private int _markId;
 
 	public TutorialShowQuestionMark(int blink)
 	{
-		_blink = blink; //this influences the blinking frequancy :S
+		_markId = blink; 
 	}
 
 	/* (non-Javadoc)
@@ -31,7 +31,7 @@ public final class TutorialShowQuestionMark extends L2GameServerPacket
 	protected void writeImpl()
 	{
 		writeC(0xa7);
-		writeD(_blink);
+		writeD(_markId);
 
 	}
 
@@ -41,7 +41,7 @@ public final class TutorialShowQuestionMark extends L2GameServerPacket
 	@Override
 	public String getType()
 	{
-		return _S__A1_TUTORIALSHOWQUESTIONMARK;
+		return _S__A7_TUTORIALSHOWQUESTIONMARK;
 	}
 
 }