[Add-on] Npc That edit your item stats

Newbie Spellweaver
Joined
Apr 13, 2010
Messages
53
Reaction score
19
So, uh this is my second release haha, I saw DeathRights NPC that edits items, but you didn't have any choice on what they edit to. So, I made this script. Like everything I've ever released, I'm 90% sure it's already been released.

NPCConversationManager:


Code:
public void gainEpicItem (byte slot, MapleCharacter player, short str, short dex, short Int, short luk, short wa, short ma) {
        MapleInventory equip = player.getInventory(MapleInventoryType.EQUIP);
        Equip eu = (Equip) equip.getItem(slot);
        int item = equip.getItem(slot).getItemId();
        MapleJob job = eu.getJob();
        short hand = eu.getHands();
        byte level = eu.getLevel();
        Equip nItem = new Equip(item, equip.getNextFreeSlot());
        nItem.setStr(str); // STR
        nItem.setDex(dex); // DEX
        nItem.setInt(Int); // INT
        nItem.setLuk(luk); //LUK
        nItem.setWatk(wa);
        nItem.setMatk(ma);
        nItem.setUpgradeSlots(nItem.getUpgradeSlots()); // Can Upgrade amount
        nItem.setJob(job);
        nItem.setHands(hand);
        nItem.setLevel(level);
        nItem.setRingId(-1);
        player.getInventory(MapleInventoryType.EQUIP).removeItem(slot);
        player.getInventory(MapleInventoryType.EQUIP).addItem(nItem);
}



Code:
public int getItemID(byte slot) {
        MapleInventory equip = getPlayer().getInventory(MapleInventoryType.EQUIP);
        Equip eu = (Equip) equip.getItem(slot);
        return equip.getItem(slot).getItemId();
    }


Code:
public Equip getEquip(byte slot) {
        MapleInventory equip = getPlayer().getInventory(MapleInventoryType.EQUIP);
        Equip eu = (Equip) equip.getItem(slot);
        return eu;
    }

PHP:
var status = -1;
var selected;
var idk;
var pe =Array("Dex", "Str", "Int", "Luk", "Wep Attack", "Mag Attack");
var d = false;
var equip;
var dex;
var str;
var iint;
var luk;
var wa;
var ma;
var a = false;
function start() {
    cm.sendNext("Since everyone is a GM here, I'm the GM equipment creator. :)");
}
function action(mode, type, selection) {
    if (mode < 1)
        cm.dispose();
    else {
        if (mode == 1 && status != 3)
            status++;
        if (status == 0)
            cm.sendSimple("What item in your inventory would you like to edit?\r\n" + cm.EquipList(cm.getC()));
        else if (status == 1) {        
            if (d == false) {
            equip = cm.getEquip(selection);
            dex = equip.getDex();
            str = equip.getStr();
            iint = equip.getInt();
            luk = equip.getLuk();
            wa = equip.getWatk();
            ma = equip.getMatk();
            selected = selection;
            d = true;
        }
            cm.sendSimple("What would you like to edit on your #b#t"+cm.getItemID(selected)+"#? #k:)" +
            "\r\n#L0##gDexterity                  #k-           #e("+dex+")#l" +
            "\r\n#n#b#L1#Strength                  #k-           #e("+str+")#l" +
            "\r\n#n#r#L2#Intelligence            #k-           #e("+iint+")#l" +
            "\r\n#n#d#L3#Luck                        #k-           #e("+luk+")#l" +
            "\r\n#g#L4#Weapon Attack    #k-           #e("+wa+")#l" +
            "\r\n#r#L5#Magic Attack        #k-           #e("+ma+")#l" +
            "\r\n\r\n#k#L6#Create item!#l");

        }
        else if (status == 2){
            if (selection == 6) {
                cm.gainEpicItem(selected, cm.getChar(), str, dex, iint, luk, wa, ma);
                cm.sendOk("Done! Relog or change channels to view the new edited item.");
                cm.dispose();
                return;
            }
                else {
                    if (a == false) {
                    idk = selection;
                    cm.sendGetText("What would you like to change your "+pe[selection]+" to?");
                    a = true;
                    } else
                        cm.sendGetText("What would you like to change your "+pe[idk]+" to?");
            
                }
            }else if (status == 3) {
            
                    var amount = parseInt(cm.getText());
                    if (amount < 0 || amount > 32767)
                        cm.sendOk("Please enter a number between 0 and 32767.");
                    else if (isNaN(amount))
                        cm.sendOk("Please enter a real number.");
                    else {
                        cm.sendOk("Done. Make any other changes you like :)");
                        switch(idk) {
                            case 0: dex = amount; break;
                            case 1: str = amount; break;
                            case 2: iint = amount; break;
                            case 3: luk = amount; break;
                            case 4: wa = amount; break;
                            case 5: ma = amount; break;  
                        }status--;
                        a = false;
                    }
                status--;
                status--;//Yeah I know I could've used status-=2.
                }
        }
    }


If you have any suggestions me making something. Do it !
I really want to help out the Maplestory Comunity.


Screen shots:

ben10 - [Add-on] Npc That edit your item stats - RaGEZONE Forums
 
Last edited:
Re: Npc That edit your item stats

This is alot similar to this
 
Last edited:
Re: Npc That edit your item stats

Thanks Crash...

Anyway on topic...

Nice Release...Here's an idea...Maybe for non-gm servers make it cost money per stat added and maybe add slots.
 
Re: Npc That edit your item stats

Hi ben10 Thx For This Nice script but sadly it didnt work for me i did all the steps and then i went to test it i typed !npc (my npc id) and then i had him poping out i talked to him then only i can see the first line this one Since everyone is a GM here, I'm the GM equipment creator. :) then when i press next> it just end the chat Oo.

Please Help Me....

And Anthour Question How to save The Npc like when i add the npc then off the server and relunch it i cant see any of the npc's that i added in the fm weird Oo. so please help me in this too.:*::*:
 
Re: Npc That edit your item stats

@liwaaa !npc (npc id) is for time only !pnpc is for always.
To fix your problem i will need to check your source if you need help come to Bestms.tk ^-^ i hope i helped you
 
Re: Npc That edit your item stats

Here Is My NPC Script I Added It To The NPC ID 9000006 Which Is The Blue Pirate Vikoon And Here What I did In His Script
Code:
/* Vikin The Item States Editior For GMS */

var status = -1;
var selected;
var idk;
var pe =Array("Dex", "Str", "Int", "Luk", "Wep Attack", "Mag Attack");
var d = false;
var equip;
var dex;
var str;
var iint;
var luk;
var wa;
var ma;
var a = false;
function start() {
    cm.sendNext("I'm the #rGM#k equipment creator. :)");
}
function action(mode, type, selection) {
    if (mode < 1)
        cm.dispose();
    else {
        if (mode == 1 && status != 3)
            status++;
        if (status == 0)
            cm.sendSimple("What item in your inventory would you like to edit the states?\r\n" + cm.EquipList(cm.getC()));
        else if (status == 1) {        
            if (d == false) {
            equip = cm.getEquip(selection);
            dex = equip.getDex();
            str = equip.getStr();
            iint = equip.getInt();
            luk = equip.getLuk();
            wa = equip.getWatk();
            ma = equip.getMatk();
            selected = selection;
            d = true;
        }
            cm.sendSimple("What would you like to edit on your #b#t"+cm.getItemID(selected)+"#? #k:)" +
            "\r\n#L0##gDexterity                  #k-           #e("+dex+")#l" +
            "\r\n#n#b#L1#Strength                  #k-           #e("+str+")#l" +
            "\r\n#n#r#L2#Intelligence            #k-           #e("+iint+")#l" +
            "\r\n#n#d#L3#Luck                        #k-           #e("+luk+")#l" +
            "\r\n#g#L4#Weapon Attack    #k-           #e("+wa+")#l" +
            "\r\n#r#L5#Magic Attack        #k-           #e("+ma+")#l" +
            "\r\n\r\n#k#L6#Create item!#l");

        }
        else if (status == 2){
            if (selection == 6) {
                cm.gainEpicItem(selected, cm.getChar(), str, dex, iint, luk, wa, ma);
                cm.sendOk("Done! Relog or change channels to view the new edited item.");
                cm.dispose();
                return;
            }
                else {
                    if (a == false) {
                    idk = selection;
                    cm.sendGetText("What would you like to change your "+pe[selection]+" to?");
                    a = true;
                    } else
                        cm.sendGetText("What would you like to change your "+pe[idk]+" to?");
            
                }
            }else if (status == 3) {
            
                    var amount = parseInt(cm.getText());
                    if (amount < 0 || amount > 32767)
                        cm.sendOk("Please enter a number between 0 and 30000.");
                    else if (isNaN(amount))
                        cm.sendOk("Please enter a real number.");
                    else {
                        cm.sendOk("Done. Make any other changes?:)");
                        switch(idk) {
                            case 0: dex = amount; break;
                            case 1: str = amount; break;
                            case 2: iint = amount; break;
                            case 3: luk = amount; break;
                            case 4: wa = amount; break;
                            case 5: ma = amount; break;  
                        }status--;
                        a = false;
                    }
                status--;
                status--;//Yeah I know I could've used status-=2.
                }
        }
    }
Waiting For Ur Help And Thx For The Help With The !pnpc Thing...:):
 
Re: Npc That edit your item stats

Code:

public int getItemID(byte slot) {
MapleInventory equip = getPlayer().getInventory(MapleInventoryType.EQUIP);
Equip eu = (Equip) equip.getItem(slot);
return equip.getItem(slot).getItemId();
}


Code:

public Equip getEquip(byte slot) {
MapleInventory equip = getPlayer().getInventory(MapleInventoryType.EQUIP);
Equip eu = (Equip) equip.getItem(slot);
return eu;
}





Where do i put these two?
 
Re: Npc That edit your item stats

Code:

public int getItemID(byte slot) {
MapleInventory equip = getPlayer().getInventory(MapleInventoryType.EQUIP);
Equip eu = (Equip) equip.getItem(slot);
return equip.getItem(slot).getItemId();
}


Code:

public Equip getEquip(byte slot) {
MapleInventory equip = getPlayer().getInventory(MapleInventoryType.EQUIP);
Equip eu = (Equip) equip.getItem(slot);
return eu;
}





Where do i put these two?

Place that into your NPCConversationManager.java in your scripting/npc folder in your server's source, and then compile.
 
Re: Npc That edit your item stats

Place that into your NPCConversationManager.java in your scripting/npc folder in your server's source, and then compile.

I will allow it this time on the grounds it could benefit others with this issue, but next time please look at the date of the last post before answering/posting.
 
can I get Help With my NPCConversationManager.java ?
I Use MapleBlade Source (NPCConversationManager.java give me errors on the NPC that was in the MapleBlade Source)
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <[email protected]>
Matthias Butz <[email protected]>
Jan Christian Meyer <[email protected]>

This prgogram is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.

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 Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package scripting.npc;

import client.Equip;
import client.IItem;
import client.ISkill;
import client.Item;
import client.ItemFactory;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import constants.ExpTable;
import client.MapleCharacter;
import client.MapleClient;
import client.MapleInventory;
import client.MapleInventoryType;
import client.MapleJob;
import client.MapleOccupations;
import client.MaplePet;
import client.MapleQuestStatus;
import client.MapleSkinColor;
import client.MapleStat;
import client.SkillFactory;
import java.awt.Point;
import tools.Randomizer;
import java.io.File;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import net.channel.ChannelServer;
import net.world.MapleParty;
import net.world.MaplePartyCharacter;
import tools.DatabaseConnection;
import net.world.guild.MapleAlliance;
import net.world.guild.MapleGuild;
import net.world.remote.WorldChannelInterface;
import provider.MapleData;
import provider.MapleDataProviderFactory;
import scripting.AbstractPlayerInteraction;
import scripting.event.EventManager;
import server.MapleInventoryManipulator;
import server.MapleItemInformationProvider;
import server.MapleShopFactory;
import server.MapleSquad;
import server.MapleSquadType;
import server.MapleStatEffect;
import server.life.MapleLifeFactory;
import server.life.MapleMonster;
import server.life.MapleMonsterStats;
import server.maps.MapleMap;
import server.maps.MapleMapObject;
import server.maps.MapleMapObjectType;
import server.quest.MapleQuest;
import tools.MaplePacketCreator;
import tools.Pair;

/**
*
* @author Matze
*/
public class NPCConversationManager extends AbstractPlayerInteraction {

private int npc;
private String getText;

public NPCConversationManager(MapleClient c, int npc) {
super(c);
this.npc = npc;
}

public int getNpc() {
return npc;
}

public void clearDrops() {
MapleMap map = getPlayer().getMap();
List<MapleMapObject> items = map.getMapObjectsInRange(getPlayer().getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
for (MapleMapObject i : items) {
map.removeMapObject(i);
map.broadcastMessage(MaplePacketCreator.removeItemFromMap(i.getObjectId(), 0, getPlayer().getId()));
}
}

public void killAllMonsters() {
MapleMap map = getPlayer().getMap();
map.killAllMonsters(false); // No drop.
}

public void summonMobAtPosition(int mobid, int amount, int posx, int posy) {
if (amount <= 1) {
MapleMonster npcmob = MapleLifeFactory.getMonster(mobid);
npcmob.setHp(npcmob.getMaxHp());
getPlayer().getMap().spawnMonsterOnGroudBelow(npcmob, new Point(posx, posy));
} else {
for (int i = 0; i < amount; i++) {
MapleMonster npcmob = MapleLifeFactory.getMonster(mobid);
npcmob.setHp(npcmob.getMaxHp());
getPlayer().getMap().spawnMonsterOnGroudBelow(npcmob, new Point(posx, posy));
}
}
}

public void spawnMob(int mapid, int mid, int xpos, int ypos) {
getClient().getChannelServer().getMapFactory().getMap(mapid).spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(mid), new Point(xpos, ypos));
}
public void summonMob(int mobid, int customHP, int customEXP, int amount) {
spawnMonster(mobid, customHP, -1, -1, customEXP, 0, 0, amount, getPlayer().getPosition().x, getPlayer().getPosition().y);
}
public void spawnMonster(int mobid, int HP, int MP, int level, int EXP, int boss, int undead, int amount, int x, int y) {
MapleMonsterStats newStats = new MapleMonsterStats();
if (HP >= 0) {
newStats.setHp(HP);
}
if (MP >= 0) {
newStats.setMp(MP);
}
if (level >= 0) {
newStats.setLevel(level);
}
if (EXP >= 0) {
newStats.setExp(EXP);
}
newStats.setBoss(boss == 1);
newStats.setUndead(undead == 1);
for (int i = 0; i < amount; i++) {
MapleMonster npcmob = MapleLifeFactory.getMonster(mobid);
npcmob.setOverrideStats(newStats);
npcmob.setHp(npcmob.getMaxHp());
npcmob.setMp(npcmob.getMaxMp());
getPlayer().getMap().spawnMonsterOnGroundBelow(npcmob, new Point(x, y));
}
}

public void dispose() {
NPCScriptManager.getInstance().dispose(this);
}

public void sendNext(String text) {
getClient().getSession().write(MaplePacketCreator.getNPCTalk(npc, (byte) 0, text, "00 01"));
}

public void sendPrev(String text) {
getClient().getSession().write(MaplePacketCreator.getNPCTalk(npc, (byte) 0, text, "01 00"));
}

public void sendNextPrev(String text) {
getClient().getSession().write(MaplePacketCreator.getNPCTalk(npc, (byte) 0, text, "01 01"));
}

public void sendOk(String text) {
getClient().getSession().write(MaplePacketCreator.getNPCTalk(npc, (byte) 0, text, "00 00"));
}

public void sendYesNo(String text) {
getClient().getSession().write(MaplePacketCreator.getNPCTalk(npc, (byte) 1, text, ""));
}

public void resetState() {
getPlayer().setState(0);
}

public void sendAcceptDecline(String text) {
getClient().getSession().write(MaplePacketCreator.getNPCTalk(npc, (byte) 0x0C, text, ""));
}

public void openShop(int id) {
MapleShopFactory.getInstance().getShop(id).sendShop(getClient());
}

public void sendSimple(String text) {
getClient().getSession().write(MaplePacketCreator.getNPCTalk(npc, (byte) 4, text, ""));
}

public void teachSkill(int id, int level, int masterlevel) {
getPlayer().changeSkillLevel(SkillFactory.getSkill(id), level, masterlevel);
}

public void sendStyle(String text, int styles[]) {
getClient().getSession().write(MaplePacketCreator.getNPCTalkStyle(npc, text, styles));
}

public void sendGetNumber(String text, int def, int min, int max) {
getClient().getSession().write(MaplePacketCreator.getNPCTalkNum(npc, text, def, min, max));
}

public void sendGetText(String text) {
getClient().getSession().write(MaplePacketCreator.getNPCTalkText(npc, text));
}

public void setGetText(String text) {
this.getText = text;
}

public List<Pair<Integer, IItem>> getStoredMerchantItems() {
Connection con = DatabaseConnection.getConnection();
List<Pair<Integer, IItem>> items = new ArrayList<Pair<Integer, IItem>>();
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM hiredmerchant WHERE ownerid = ? AND onSale = false");
ps.setInt(1, getPlayer().getId());
ResultSet rs = ps.executeQuery();
while (rs.next()) {
if (rs.getInt("type") == 1) {
Equip eq = new Equip(rs.getInt("itemid"), (byte) 0, -1);
eq.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
eq.setLevel((byte) rs.getInt("level"));
eq.setStr((short) rs.getInt("str"));
eq.setDex((short) rs.getInt("dex"));
eq.setInt((short) rs.getInt("int"));
eq.setLuk((short) rs.getInt("luk"));
eq.setHp((short) rs.getInt("hp"));
eq.setMp((short) rs.getInt("mp"));
eq.setWatk((short) rs.getInt("watk"));
eq.setMatk((short) rs.getInt("matk"));
eq.setWdef((short) rs.getInt("wdef"));
eq.setMdef((short) rs.getInt("mdef"));
eq.setAcc((short) rs.getInt("acc"));
eq.setAvoid((short) rs.getInt("avoid"));
eq.setHands((short) rs.getInt("hands"));
eq.setSpeed((short) rs.getInt("speed"));
eq.setJump((short) rs.getInt("jump"));
eq.setOwner(rs.getString("owner"));
items.add(new Pair<Integer, IItem>(rs.getInt("id"), eq));
} else if (rs.getInt("type") == 2) {
Item newItem = new Item(rs.getInt("itemid"), (byte) 0, (short) rs.getInt("quantity"));
newItem.setOwner(rs.getString("owner"));
items.add(new Pair<Integer, IItem>(rs.getInt("id"), newItem));
}
}
ps.close();
rs.close();
} catch (SQLException se) {
se.printStackTrace();
return null;
}
return items;
}

public void removeHiredMerchantItem(int id) {
try {
List<Pair<IItem, MapleInventoryType>> workingList = getHiredMerchantItems();
for (Pair<IItem, MapleInventoryType> p : workingList) {
if (p.getLeft().getDBID() == id) {
workingList.remove(p);
break;
}
}
ItemFactory.MERCHANT.saveItems(workingList, c.getPlayer().getId());
c.getPlayer().saveToDB(true);
} catch (Exception e) {
}
}

public List<Pair<IItem, MapleInventoryType>> getHiredMerchantItems() {
try {
return ItemFactory.MERCHANT.loadItems(c.getPlayer().getId(), false);
} catch (Exception e) {
System.out.println("Error loading merchant items:");
e.printStackTrace();
}
return null;
}


public String getText() {
return this.getText;
}

public int getJobId() {
return getPlayer().getJob().getId();
}

public void startQuest(int id) {
try {
MapleQuest.getInstance(id).forceStart(getPlayer(), npc);
} catch (NullPointerException ex) {
}
}

public void resetReactors() {
c.getPlayer().getMap().resetReactors();
}

public void completeQuest(int id) {
try {
MapleQuest.getInstance(id).forceComplete(getPlayer(), npc);
} catch (NullPointerException ex) {
}
}

public int getMeso() {
return getPlayer().getMeso();
}
public void gainReborns(int reborns) {
getPlayer().setReborns(reborns + getPlayer().getReborns());
}
public void reloadChar() {
getPlayer().getClient().getSession().write(MaplePacketCreator.getCharInfo(getPlayer()));
getPlayer().getMap().removePlayer(getPlayer());
getPlayer().getMap().addPlayer(getPlayer());
}

public void gainMeso(int gain) {
getPlayer().gainMeso(gain, true, false, true);
}

public void openNpc(int npcid){
NPCScriptManager npc = NPCScriptManager.getInstance();
npc.start(c, npcid, null, null);
}

public void gainExp(int gain) {
getPlayer().gainExp(gain, true, true);
}

public int getLevel() {
return getPlayer().getLevel();
}

public MapleCharacter getP() {
return getPlayer();
}

public void giveRandItem(int itemid) {
Equip e = (Equip) MapleItemInformationProvider.getInstance().getEquipById(itemid);
e.setStr((short) (Math.random() * 50 + 100));
e.setDex((short) (Math.random() * 50 + 100));
e.setInt((short) (Math.random() * 50 + 100));
e.setLuk((short) (Math.random() * 50 + 100));
MapleInventoryManipulator.addFromDrop(c, e);
}

public void giveRandItem1(int itemid) {
Equip e = (Equip) MapleItemInformationProvider.getInstance().getEquipById(itemid);
e.setStr((short) (Math.random() * 50 + 250));
e.setDex((short) (Math.random() * 50 + 250));
e.setInt((short) (Math.random() * 50 + 250));
e.setLuk((short) (Math.random() * 50 + 250));
MapleInventoryManipulator.addFromDrop(c, e);
}
public void giveRandItem2(int itemid) {
Equip e = (Equip) MapleItemInformationProvider.getInstance().getEquipById(itemid);
e.setStr((short) (Math.random() * 50 + 450));
e.setDex((short) (Math.random() * 50 + 450));
e.setInt((short) (Math.random() * 50 + 450));
e.setLuk((short) (Math.random() * 50 + 450));
MapleInventoryManipulator.addFromDrop(c, e);
}


public String EquipList(MapleClient c) {
StringBuilder str = new StringBuilder();
MapleInventory equip = c.getPlayer().getInventory(MapleInventoryType.EQUIP);
List<String> stra = new LinkedList<String>();
for (IItem item : equip.list()) {
stra.add("#L"+item.getPosition()+"##v"+item.getItemId()+"##l");
}
for (String strb : stra) {
str.append(strb);
}
return str.toString();
}

public void maxAranskills() {
for (MapleData skill_ : MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" + "String.wz")).getData("Skill.img").getChildren()) {
try {
ISkill skill = SkillFactory.getSkill(Integer.parseInt(skill_.getName()));
if (skill.getId() < 1009 || skill.getId() > 1011) {
c.getPlayer().changeSkillLevel(skill, skill.getMaxLevel(), skill.getMaxLevel());
}
} catch (NumberFormatException nfe) {
break;
} catch (NullPointerException npe) {
continue;
}
}
}
public EventManager getEventManager(String event) {
return getClient().getChannelServer().getEventSM().getEventManager(event);
}

public void changeOccupationById(int occ) {
getPlayer().changeOccupation(MapleOccupations.getById(occ));
}

public boolean HasOccupation() {
return (getPlayer().getOccupation().getId() % 100 == 0);
}public boolean HasOccupation0() {
return (getPlayer().getOccupation().getId() == 1);
}public boolean HasOccupation1() {
return (getPlayer().getOccupation().getId() == 100);
}public boolean HasOccupation2() {
return (getPlayer().getOccupation().getId() == 110);
}public boolean HasOccupation3() {
return (getPlayer().getOccupation().getId() == 120);
}public boolean HasOccupation4() {
return (getPlayer().getOccupation().getId() == 130);
}public boolean HasOccupation5() {
return (getPlayer().getOccupation().getId() == 140);
}public boolean HasOccupation6() {
return (getPlayer().getOccupation().getId() == 150);
}public boolean HasOccupation7() {
return (getPlayer().getOccupation().getId() == 160);
}public boolean HasOccupation8() {
return (getPlayer().getOccupation().getId() == 170);
}public boolean HasOccupation9() {
return (getPlayer().getOccupation().getId() == 180);
}public boolean HasOccupation10() {
return (getPlayer().getOccupation().getId() == 190);
}

public int getVotePoints() {
return getPlayer().getVotePoints();
}

public void setVotePoints(int ****) {
getPlayer().setVotePoints(getPlayer().getVotePoints() + ****);
}

public void showEffect(String effect) {
getPlayer().getMap().broadcastMessage(MaplePacketCreator.environmentChange(effect, 3));
}

public void playSound(String sound) {
getPlayer().getMap().broadcastMessage(MaplePacketCreator.environmentChange(sound, 4));
}

public void setHair(int hair) {
getPlayer().setHair(hair);
getPlayer().updateSingleStat(MapleStat.HAIR, hair);
getPlayer().equipChanged();
}

public void setFace(int face) {
getPlayer().setFace(face);
getPlayer().updateSingleStat(MapleStat.FACE, face);
getPlayer().equipChanged();
}

public void setSkin(int color) {
getPlayer().setSkinColor(MapleSkinColor.getById(color));
getPlayer().updateSingleStat(MapleStat.SKIN, color);
getPlayer().equipChanged();
}

public void setLevelz(int level) {
getPlayer().setLevel(10);
}

public void setLevelx(int level) {
getPlayer().setLevel(8);
}

public int itemQuantity(int itemid) {
return getPlayer().getInventory(MapleItemInformationProvider.getInstance().getInventoryType(itemid)).countById(itemid);
}

public void displayGuildRanks() {
MapleGuild.displayGuildRanks(getClient(), npc);
}

public void environmentChange(String env, int mode) {
getPlayer().getMap().broadcastMessage(MaplePacketCreator.environmentChange(env, mode));
}

public void gainCloseness(int closeness) {
for (MaplePet pet : getPlayer().getPets()) {
if (pet.getCloseness() > 30000) {
pet.setCloseness(30000);
return;
}
pet.gainCloseness(closeness);
while (pet.getCloseness() > ExpTable.getClosenessNeededForLevel(pet.getLevel())) {
pet.setLevel(pet.getLevel() + 1);
getClient().getSession().write(MaplePacketCreator.showOwnPetLevelUp(getPlayer().getPetIndex(pet)));
}
getPlayer().getClient().getSession().write(MaplePacketCreator.updatePet(pet));
}
}

public String getName() {
return getPlayer().getName();
}

public int getGender() {
return getPlayer().getGender();
}

public void modifyNX(int amount, int type) {
getPlayer().addCSPoints(type, amount);
if (amount > 0) {
getClient().getSession().write(MaplePacketCreator. serverNotice(5, "You have gained NX Cash (+" + amount +")."));
} else {
getClient().getSession().write(MaplePacketCreator. serverNotice(5, "You have lost NX Cash (" + (amount) +")."));
}
}

public void changeJobById(int a) {
getPlayer().changeJob(MapleJob.getById(a));
}

public void addRandomItem(int id) {
MapleItemInformationProvider i = MapleItemInformationProvider.getInstance();
MapleInventoryManipulator.addFromDrop(getClient(), i.randomizeStats((Equip) i.getEquipById(id)), true);
}

public MapleJob getJobName(int id) {
return MapleJob.getById(id);
}

public boolean isQuestCompleted(int quest) {
try {
return getQuestStatus(quest) == MapleQuestStatus.Status.COMPLETED;
} catch (NullPointerException e) {
return false;
}
}

public boolean isQuestStarted(int quest) {
try {
return getQuestStatus(quest) == MapleQuestStatus.Status.STARTED;
} catch (NullPointerException e) {
return false;
}
}

public void sendCygnusCharCreate() {
c.getSession().write(MaplePacketCreator.sendCygnusCreateChar());
}

public MapleStatEffect getItemEffect(int itemId) {
return MapleItemInformationProvider.getInstance().getItemEffect(itemId);
}

public void resetStats() {
int totAp = getPlayer().getStr() + getPlayer().getDex() + getPlayer().getLuk() + getPlayer().getInt() + getPlayer().getRemainingAp();
getPlayer().setStr(4);
getPlayer().setDex(4);
getPlayer().setLuk(4);
getPlayer().setInt(4);
getPlayer().setRemainingAp(totAp - 16);
getPlayer().updateSingleStat(MapleStat.STR, 4);
getPlayer().updateSingleStat(MapleStat.DEX, 4);
getPlayer().updateSingleStat(MapleStat.LUK, 4);
getPlayer().updateSingleStat(MapleStat.INT, 4);
getPlayer().updateSingleStat(MapleStat.AVAILABLEAP, totAp);
}

public void maxMastery() {
for (MapleData skill_ : MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" + "String.wz")).getData("Skill.img").getChildren()) {
try {
ISkill skill = SkillFactory.getSkill(Integer.parseInt(skill_.getName()));
if ((skill.getId() / 10000 % 10 == 2 || (getClient().getPlayer().isCygnus() && skill.getId() / 10000 % 10 == 1)) && getPlayer().getSkillLevel(skill) < 1) {
getPlayer().changeSkillLevel(skill, 0, skill.getMaxLevel());
}
} catch (NumberFormatException nfe) {
break;
} catch (NullPointerException npe) {
continue;
}
}
}

public void processGachapon(int[] id, boolean remote) {
int[] gacMap = {100000000, 101000000, 102000000, 103000000, 105040300, 800000000, 809000101, 809000201, 600000000, 120000000};
int itemid = id[Randomizer.getInstance().nextInt(id.length)];
addRandomItem(itemid);
if (!remote) {
gainItem(5220000, (short) -1);
}
sendNext("You have obtained a #b#t" + itemid + "##k.");
//getClient().getChannelServer().broadcastPacket(MaplePacketCreator.gachaponMessage(getPlayer().getInventory(MapleInventoryType.getByType((byte) (itemid / 1000000))).findById(itemid), c.getPlayer().getMapName(gacMap[(getNpc() != 9100117 && getNpc() != 9100109) ? (getNpc() - 9100100) : getNpc() == 9100109 ? 8 : 9]), getPlayer()));
}

public void disbandAlliance(MapleClient c, int allianceId) {
PreparedStatement ps = null;
try {
ps = DatabaseConnection.getConnection().prepareStatement("DELETE FROM `alliance` WHERE id = ?");
ps.setInt(1, allianceId);
ps.executeUpdate();
ps.close();
c.getChannelServer().getWorldInterface().allianceMessage(c.getPlayer().getGuild().getAllianceId(), MaplePacketCreator.disbandAlliance(allianceId), -1, -1);
c.getChannelServer().getWorldInterface().disbandAlliance(allianceId);
} catch (RemoteException r) {
c.getChannelServer().reconnectWorld();
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
try {
if (ps != null) {
ps.close();
}
} catch (SQLException ex) {
}
}
}

public boolean canBeUsedAllianceName(String name) {
if (name.contains(" ") || name.length() > 12) {
return false;
}
try {
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT name FROM alliance WHERE name = ?");
ps.setString(1, name);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
ps.close();
rs.close();
return false;
}
ps.close();
rs.close();
return true;
} catch (SQLException e) {
return false;
}
}

public static MapleAlliance createAlliance(MapleCharacter chr1, MapleCharacter chr2, String name) {
int id = 0;
int guild1 = chr1.getGuildId();
int guild2 = chr2.getGuildId();
try {
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO `alliance` (`name`, `guild1`, `guild2`) VALUES (?, ?, ?)");
ps.setString(1, name);
ps.setInt(2, guild1);
ps.setInt(3, guild2);
ps.executeUpdate();
ResultSet rs = ps.getGeneratedKeys();
rs.next();
id = rs.getInt(1);
rs.close();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
return null;
}
MapleAlliance alliance = new MapleAlliance(name, id, guild1, guild2);
try {
WorldChannelInterface wci = chr1.getClient().getChannelServer().getWorldInterface();
wci.setGuildAllianceId(guild1, id);
wci.setGuildAllianceId(guild2, id);
chr1.setAllianceRank(1);
chr1.saveGuildStatus();
chr2.setAllianceRank(2);
chr2.saveGuildStatus();
wci.addAlliance(id, alliance);
wci.allianceMessage(id, MaplePacketCreator.makeNewAlliance(alliance, chr1.getClient()), -1, -1);
} catch (RemoteException e) {
chr1.getClient().getChannelServer().reconnectWorld();
chr2.getClient().getChannelServer().reconnectWorld();
return null;
}
return alliance;
}


public void MakeGMItem (byte slot, MapleCharacter player) {
MapleInventory equip = player.getInventory(MapleInventoryType.EQUIP);
Equip eu = (Equip) equip.getItem(slot);
int item = equip.getItem(slot).getItemId();
MapleJob job = eu.getJob();
short hand = eu.getHands();
byte level = eu.getLevel();
Equip nItem = new Equip(item, equip.getNextFreeSlot());
nItem.setStr((short) 32767); // STR
nItem.setDex((short) 32767); // DEX
nItem.setInt((short) 32767); // INT
nItem.setLuk((short) 32767); //LUK
nItem.setUpgradeSlots((byte) 0);
nItem.setJob(job);
nItem.setHands(hand);
nItem.setLevel(level);
player.getInventory(MapleInventoryType.EQUIP).addFromDB(nItem);
}




public List<MapleCharacter> getPartyMembers() {
if (getPlayer().getParty() == null) {
return null;
}
List<MapleCharacter> chars = new LinkedList<MapleCharacter>();
for (ChannelServer channel : ChannelServer.getAllInstances()) {
for (MapleCharacter chr : channel.getPartyMembers(getPlayer().getParty(), -1)) {
if (chr != null) {
chars.add(chr);
}
}
}
return chars;
}

public void warpParty(int id) {
for (MapleCharacter mc : getPartyMembers()) {
if (id == 925020100) {
mc.setDojoParty(true);
}
mc.changeMap(getWarpMap(id));
}
}


public int getHiredMerchantMesos(boolean zero) {
int mesos = 0;
PreparedStatement ps = null;
Connection con = DatabaseConnection.getConnection();
try {
ps = con.prepareStatement("SELECT MerchantMesos FROM characters WHERE id = ?");
ps.setInt(1, getPlayer().getId());
ResultSet rs = ps.executeQuery();
if (rs.next()) {
mesos = rs.getInt("MerchantMesos");
}
rs.close();
ps.close();
if (zero) {
ps = con.prepareStatement("UPDATE characters SET MerchantMesos = 0 WHERE id = ?");
ps.setInt(1, getPlayer().getId());
ps.executeUpdate();
ps.close();
}
} catch (SQLException e) {
} finally {
try {
if (ps != null) {
ps.close();
}
} catch (SQLException ex) {
}
}
return mesos;
}

public void setHiredMerchantMesos(int mesos) {
try {
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET MerchantMesos = ? WHERE id = ?");
ps.setInt(1, mesos);
ps.setInt(2, getPlayer().getId());
ps.executeUpdate();
ps.close();
} catch (SQLException e) {
}
}


public int partyMembersInMap() {
int inMap = 0;
for (MapleCharacter char2 : getPlayer().getMap().getCharacters()) {
if (char2.getParty() == getPlayer().getParty()) {
inMap++;
}
}
return inMap;
}

public MapleCharacter getChar() {
return getPlayer();
}

public MapleCharacter getSquadMember(MapleSquadType type, int index) {
MapleSquad squad = c.getChannelServer().getMapleSquad(type);
MapleCharacter ret = null;
if (squad != null) {
ret = squad.getMembers().get(index);
}
return ret;
}

public void addSquadMember(MapleSquadType type) {
MapleSquad squad = c.getChannelServer().getMapleSquad(type);
if (squad != null) {
squad.addMember(getPlayer());
}
}

public int getAverageLevel(MapleParty mp) {
int total = 0;
for (MaplePartyCharacter mpc : mp.getMembers()) {
total += mpc.getLevel();
}
return total / mp.getMembers().size();
}
public void gainEpicItem (byte slot, MapleCharacter player, short str, short dex, short Int, short luk, short wa, short ma) {
MapleInventory equip = player.getInventory(MapleInventoryType.EQUIP);
Equip eu = (Equip) equip.getItem(slot);
int item = equip.getItem(slot).getItemId();
MapleJob job = eu.getJob();
short hand = eu.getHands();
byte level = eu.getLevel();
Equip nItem = new Equip(item, equip.getNextFreeSlot());
nItem.setStr(str); // STR
nItem.setDex(dex); // DEX
nItem.setInt(Int); // INT
nItem.setLuk(luk); //LUK
nItem.setWatk(wa);
nItem.setMatk(ma);
nItem.setUpgradeSlots(nItem.getUpgradeSlots()); // Can Upgrade amount
nItem.setJob(job);
nItem.setHands(hand);
nItem.setLevel(level);
nItem.setRingId(-1);
player.getInventory(MapleInventoryType.EQUIP).removeItem(slot);
player.getInventory(MapleInventoryType.EQUIP).addItem(nItem);
}
public int getItemID(byte slot) {
MapleInventory equip = getPlayer().getInventory(MapleInventoryType.EQUIP);
Equip eu = (Equip) equip.getItem(slot);
return equip.getItem(slot).getItemId();
}
public Equip getEquip(byte slot) {
MapleInventory equip = getPlayer().getInventory(MapleInventoryType.EQUIP);
Equip eu = (Equip) equip.getItem(slot);
return eu;
}
}
I can't Open some Store's or half of them dont work, its say the NPC dont work and report it to Stuff....etc... :mellow::mellow:
 
Sorry if this thread is inactive but,
Where am I supposed to put the 2 codes in ConversationHandler.java (something like that)?

I tried putting them at the end but nothing happened. Still returns the error "This NPC is not working properly. Please Report it."

[If thread is inactive, PM me.]
 
Back