PDA

View Full Version : [508] NPCOption3[Packet 199]



Mod_Cubsmiles
June 23rd, 2010, 14:14
Purpose: To support packet 199.

Difficulty: 9/10

Files Modified: Player.class, PacketManager.class

Files Created: NPCOption3.class

Credits: The Java Guru(Annexation), and Me.


Step 1:
Go into your Packet Handler Folder.
Add this:*CHANGE THE IMPORTS TO YOURS*
Name it: NPCOption3.java

/*
* Class NPCOption3
*
* Version 1.0
*
* Sunday, September 13, 2009
*
* Created by a Person
*/

package net.com.codeusa.net.packethandler;

import net.com.codeusa.Server;
import net.com.codeusa.Engine;
import net.com.codeusa.npcs.*;
import net.com.codeusa.model.skills.*;
import net.com.codeusa.model.games.*;
import net.com.codeusa.model.combat.*;
import net.com.codeusa.model.Player;
import net.com.codeusa.util.Misc;

public class NPCOption3 implements Packet {

public void handlePacket(Player p, int packetId, int packetSize) {
if (p == null || p.stream == null) {
return;
}
if (!p.npcOption3) {
int npcId = p.stream.readUnsignedWordBigEndian();
if (npcId <= 0 || npcId >= Engine.npcs.length || Engine.npcs[npcId] == null) {
return;
}
p.clickId = npcId;
p.clickX = Engine.npcs[npcId].absX;
p.clickY = Engine.npcs[npcId].absY;
if (Misc.getDistance(p.absX, p.absY, p.clickX, p.clickY) > 30) {
return;
}
p.npcOption3 = true;
}
if (p.clickId <= 0 || p.clickId >= Engine.npcs.length || Engine.npcs[p.clickId] == null) {
p.npcOption3 = false;
return;
}
if (Misc.getDistance(p.absX, p.absY, p.clickX, p.clickY) > 1) {
return;
}
p.npcOption3 = false;
switch (p.clickId) {
default:
Misc.println("[" + p.username + "] Unhandled npc option 3: " + p.clickId);
break;
}
}
}


Step 2:
Open up PacketManager.java
Search for:

public NPCOption2 npcOption2 = new NPCOption2();
Under it, add:

public NPCOption3 npcOption3 = new NPCOption3();

Step 3:
Search for:

case 52:
You should see:

case 52:
/*
* Second NPC option.
*/
npcOption2.handlePacket(p, packetId, packetSize);
break;

Under it, add:

case 199:
/*
* Third NPC option.
*/
npcOption3.handlePacket(p, packetId, packetSize);
break;

Step 4:
Open up Player.java
Search for:

public boolean npcOption2 = false;
Under it, add:

/**
* Clicked the third option on a NPC.
*/
public boolean npcOption3 = false;

Step 5:
Search for:

if (npcOption2) {
Under:

if (npcOption2) {
Engine.packets.npcOption2.handlePacket(this, 0, 0);
}
Add:

if (npcOption3) {
Engine.packets.npcOption3.handlePacket(this, 0, 0);
}

Step 6:
Search for:

npcOption2 = false;
Under it, add:

npcOption3 = false;

There you go.

Nick
June 24th, 2010, 22:16
may i ask what does this acutally do?

Mod_Cubsmiles
June 25th, 2010, 02:51
Npcs that have the 3rd option such as at bankers have the "collect" option, this packet handles it.

Faab234
June 25th, 2010, 07:09
This is like a copy of NPCOption1/2, but nice job.

Mod_Cubsmiles
June 25th, 2010, 20:50
This is like a copy of NPCOption1/2, but nice job.

Yeah kinda, but the file is different.