L2JMobius

High Five Share More custom to Noblesse Manager

seanet · 3 · 3969

Offline seanet

  • Heir
  • **
    • Posts: 11
I have decided to mod a little the current nobless npc to make the npc a little harder than a simple click
Modifications:
Check if player has subclass active if not noblesse is refused.
Check if player has Caradine Letter in his inventory.
Added a little social action.

Hope it helps someone

NoblessManager.java
Quote
/*
 * This file is part of the L2J Mobius project.
 *
 * 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.NoblessMaster;

import org.l2jmobius.Config;
import org.l2jmobius.gameserver.data.xml.impl.ExperienceData;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;

import ai.AbstractNpcAI;

/**
 * @author Mobius
 */
public class NoblessMaster extends AbstractNpcAI
{
   private static final int NOBLESS_TIARA = 7694;
   private static final int CARADINE_LETTER = 7678;
   
   private NoblessMaster()
   {
      addStartNpc(Config.NOBLESS_MASTER_NPCID);
      addTalkId(Config.NOBLESS_MASTER_NPCID);
      addFirstTalkId(Config.NOBLESS_MASTER_NPCID);
   }
   
   @Override
   public String onAdvEvent(String event, Npc npc, PlayerInstance player)
   {
      if (!Config.NOBLESS_MASTER_ENABLED)
      {
         return null;
      }
      
      switch (event)
      {
         case "noblesse":
         {
            //A retail-like approach player can't become noblesse, if is not on his subclass.
            if (!player.isSubClassActive())
            {
            return "1003000-4.htm";
            }
               if (player.isNoble()) //Checkpoint see if player has noblesse status.
               {
               return "1003000-3.htm";
               }
                  if (player.getLevel() >= Config.NOBLESS_MASTER_LEVEL_REQUIREMENT)
                  {
                     if (getQuestItemsCount(player, CARADINE_LETTER) >= 1)
                     {
                     takeItems(player, CARADINE_LETTER, 1);
                     giveItems(player, NOBLESS_TIARA, 1);
                     player.setNoble(true);
                     player.sendPacket(new SocialAction(player.getObjectId(), 3));
                     return "1003000-1.htm";
                     }
                  }
               return "1003000-2.htm";
            }
         }
      
      return null;
   }
   
   @Override
   public String onFirstTalk(Npc npc, PlayerInstance player)
   {
      return "1003000.htm";
   }
   
   public static void main(String[] args)
   {
      new NoblessMaster();
   }
}


1003000.htm
Quote
<html><body>
Noblesse Master:<br>
Hello adventurer,<br1>
I was sent by the gods to help adventurers to become noble.<br>
In order to become noble you need first to be<br1>
level 76,on your first subclass<br1>
and own in your inventory <font color="LEVEL">Caradine Letter</font>.<br>
<br>
<a action="bypass -h Quest NoblessMaster noblesse">I am ready, make me noble.</a>
</body></html>

1003000-1.htm
Quote
<html><body>
Noblesse Master:<br>
Congratulations anventurer!<br1>
You are now a Noble man/woman.<br1>
You can benefit from Noblesse Blessing and<br1>
dont forget to visit the gatekeepers,<br1>
now they can teleport you to more places.
</body></html>

1003000-2.htm
Quote
<html><body>
Noblesse Master:<br>
You must be at least level 76 and own Caradine Letter to become noblesse!
</body></html>

1003000.-3.htm
Quote
<html><body>
Noblesse Master:<br>
Aventurer, stop annoying me, you are already a noble.
</body></html>

1003000-4.htm
Quote
<html><body>
Noblesse Master:<br>
You need to be on your subclass first in order to become noble.
</body></html>

game/config/custom/NoblessMaster.ini
Quote
---------------------------------------------------------------------------
# Nobless Master (instant nobless NPC)
#
# Player needs Caradine Letter Item id 7693 to become noble.
# If item id needs replacement check in 
# /data/scripts/custom/NoblessMaster/NoblessMaster.java
---------------------------------------------------------------------------


Offline slayerofdark

  • Heir
  • **
    • Posts: 23
Code: [Select]
/*
 * This file is part of the L2J Mobius project.
 *
 * 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.NoblessMaster;

import org.l2jmobius.Config;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Player;

import ai.AbstractNpcAI;

/**
 * @author Mobius
 */
public class NoblessMaster extends AbstractNpcAI
{
// Item
private static final int NOBLESS_TIARA = 7694;
private static final int CARADINE_LETTER = 7678;

private NoblessMaster()
{
addStartNpc(Config.NOBLESS_MASTER_NPCID);
addTalkId(Config.NOBLESS_MASTER_NPCID);
addFirstTalkId(Config.NOBLESS_MASTER_NPCID);
}

@Override
public String onAdvEvent(String event, Npc npc, Player player)
{
if (!Config.NOBLESS_MASTER_ENABLED)
{
return null;
}

switch (event)
{
case "noblesse":
{
// A retail-like approach player can't become noblesse, if is not on his subclass.
if (!player.isSubClassActive())
{
return "1003000-4.htm";
}
}
{
if (player.isNoble())
{
return "1003000-3.htm";
}
if (player.getLevel() > Config.NOBLESS_MASTER_LEVEL_REQUIREMENT)
{
if (getQuestItemsCount(player, CARADINE_LETTER) > 1)
{
{

if (Config.NOBLESS_MASTER_REWARD_TIARA)
{
takeItems(player, CARADINE_LETTER, 1);
giveItems(player, NOBLESS_TIARA, 1);
}
}
player.setNoble(true);
player.sendPacket(QuestSound.ITEMSOUND_QUEST_FINISH.getPacket());
return "1003000-1.htm";
}
}
return "1003000-2.htm";
}
}

return null;
}

@Override
public String onFirstTalk(Npc npc, Player player)
{
return "1003000.htm";
}

public static void main(String[] args)
{
new NoblessMaster();
}
}


main code fix for newer version