L2JMobius

C6 Simple Npc Buffer (Basic)

Reanimation · 7 · 1327

Offline Reanimation

  • Knight
  • ***
    • Posts: 63
Hello everyone!

How are they? I hope it's ok!

Well, here I come to leave you a code for a simple buffer npc, this npc is basic and the code is also very basic.

I share this since I have seen topics where new forum users search for and/or request a simple npc buffer, other than the one that already comes with the source (schemme buffer).

This npc is quite simple, in the next few days I may bring it with an update and improvement to make it a good npc.




Here you have the direct link to the code so you can add them to your l2jmobius_c6_interlude source.

https://pastebin.com/dF0CBNvV


If you have any questions or queries, you can write to me.

Kind regards



Offline secaolol

  • Knight
  • ***
    • Posts: 61

Offline Reanimation

  • Knight
  • ***
    • Posts: 63
u can adapt to classic interlude? *-*

Hello, here I adapted it to this basic code for npc simple direct buffer for Classic Interlude.

Code: [Select]
package org.l2jmobius.gameserver.model.actor.instance;

import java.util.StringTokenizer;

import org.l2jmobius.gameserver.data.xml.SkillData;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;

/**
 * @author Trance, Bluur
 * @adapted for L2jmobius Reanimation
 */
public final class Buffer extends Npc
{
public Buffer(NpcTemplate template)
{
super(template);
}

@Override
public void onBypassFeedback(Player player, String command)
{
StringTokenizer st = new StringTokenizer(command, " ");
String actualCommand = st.nextToken();

int buffid = 0, bufflevel = 1;
if (st.countTokens() == 2)
{
buffid = Integer.valueOf(st.nextToken());
bufflevel = Integer.valueOf(st.nextToken());
}
else if (st.countTokens() == 1)
{
buffid = Integer.valueOf(st.nextToken());
}

if (actualCommand.equalsIgnoreCase("getbuff"))
{
SkillData.getInstance().getSkill(buffid, bufflevel).applyEffects(this, player);
broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 500, 0));
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(player, getHtmlPath(getId(), 0, player));
html.replace("%objectId%", getObjectId());
player.sendPacket(html);
}
else if (actualCommand.equalsIgnoreCase("restore"))
{
player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
player.setCurrentCp(player.getMaxCp());

broadcastPacket(new MagicSkillUse(this, player, 1258, 4, 500, 0));
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(player, getHtmlPath(getId(), 0, player));
html.replace("%objectId%", getObjectId());
player.sendPacket(html);
}
else if (actualCommand.equalsIgnoreCase("cancel"))
{
player.stopAllEffects();
broadcastPacket(new MagicSkillUse(this, player, 1056, 12, 500, 0));
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(player, getHtmlPath(getId(), 0, player));
html.replace("%objectId%", getObjectId());
player.sendPacket(html);
}
else
{
super.onBypassFeedback(player, command);
}
}

@Override
public String getHtmlPath(int npcId, int value, Player player)
{
String filename = "";
if (value == 0)
{
filename = Integer.toString(npcId);
}
else
{
filename = npcId + "-" + value;
}
return "data/html/mods/Buffer/" + filename + ".htm";
}

}

The html do not change, they are the same as the original post, but the SQL is no longer used, you will have to create a new npc, in the folder directly in its corresponding xml:
>L2jMobius Classic Interlude\game\data\stats\npcs\custom
Code: [Select]
<npc id="50009" displayId="9000" type="Buffer" name="Rosalina" usingServerSideName="true" title="Simple Basic Buffer" usingServerSideTitle="true">
<race>HUMAN</race>
<sex>FEMALE</sex>
<stats>
<vitals hp="2444.46819" hpRegen="7.5" mp="1345.8" mpRegen="2.7" />
<attack physical="688.86373" magical="470.40463" random="30" critical="4" accuracy="95" attackSpeed="253" type="SWORD" range="40" distance="80" width="120" />
<defence physical="295.91597" magical="216.53847" />
<speed>
<walk ground="50" />
<run ground="120" />
</speed>
</stats>
<status attackable="false" />
<collision>
<radius normal="11" />
<height normal="22.25" />
</collision>
</npc>

Remember that this adaptation is only for the basic function of the NPC.

I have a new improved version, if you are interested, send me a pm.



Offline sebahomsi

  • Vassal
  • *
    • Posts: 3
I dont know why.. but the html is not working for me.
The NPC returns me a dialog like this:
Html was so long,
Try to use DB for this action.


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 342
This means that your html was too big. Try to add fewer skills or add pagination.


Offline beetwinz

  • Vassal
  • *
    • Posts: 3


https://pastebin.com/dF0CBNvV



iam sorry, iam not expert in programing, and i just play as fun with this game.
can you tell me where i can add that file in server file? and what i must to do change in any server file?


Offline Reanimation

  • Knight
  • ***
    • Posts: 63
iam sorry, iam not expert in programing, and i just play as fun with this game.
can you tell me where i can add that file in server file? and what i must to do change in any server file?

Hello, if there is no problem, look at everything that is there, you can include it in a patch and apply it to the source in your program with which you are compiling the data from your server. If you want you can do it manually, but there you would have to follow and guide yourself according to the names of the files indicated within the lines of codes that are seen in what I shared