Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Add-On]Learning NPCs, Start to Finish

Status
Not open for further replies.
Newbie Spellweaver
Joined
Jun 21, 2010
Messages
6
Reaction score
0
Re: Learning NPCs, Start to Finish

Great tutorial. I have a question: Is there a way to clutter a large text into more than one line with cm.SendNext("text") command?
 
bleh....
Loyal Member
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,129
Re: Learning NPCs, Start to Finish

Great tutorial. I have a question: Is there a way to clutter a large text into more than one line with cm.SendNext("text") command?

You'll need to explain better. I'm confused by what you mean.
 
Newbie Spellweaver
Joined
Feb 5, 2010
Messages
9
Reaction score
0
Re: Learning NPCs, Start to Finish

I'm sorry but if you see the part where it says
Code:
if (cm.haveItem(item, ammount) {
i belive that its:
Code:
if (cm.haveItem(item, ammount)) {
 
bleh....
Loyal Member
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,129
Re: Learning NPCs, Start to Finish

I'm sorry but if you see the part where it says
Code:
if (cm.haveItem(item, ammount) {
i belive that its:
Code:
if (cm.haveItem(item, ammount)) {

Yes, you're right. I was probably rushing it out. I'll fix it now.

EDIT: Fixed. I might be redoing this since I've learned a bit more since posting this.
 
Last edited:
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: Learning NPCs, Start to Finish

Code:
var status = 0;


function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
		cm.sendSimple("Hey #b#h ##k, I am here to max your mastery! Please select your job to max : \r\n#L0##rI AM ARAN!#l#k\r\n#L1##rI AM AVENGER!#l#k\r\n#L2##rI AM CYGNUS KNIGHT!#l#k\r\n#L3##rSorry I don't need max mastery!#l#k");
	if (selection == 0) {
	if (cm.getAranPoint() < 1 && cm.getJobId() > 1999) {
		cm.teachSkill(20001004,1,1);
		cm.teachSkill(21000000,0,10);
		cm.teachSkill(21000002,0,20);
		cm.teachSkill(21001001,0,15);
		cm.teachSkill(21001003,0,20);
		cm.teachSkill(21100000,0,20);
		cm.teachSkill(21100001,0,20);
		cm.teachSkill(21100002,0,30);
		cm.teachSkill(21100004,0,20);
		cm.teachSkill(21100005,0,20);
		cm.teachSkill(21101003,0,20);
		cm.teachSkill(21110000,0,20);
		cm.teachSkill(21110002,0,20);
		cm.teachSkill(21110003,0,30);
		cm.teachSkill(21110004,0,30);
		cm.teachSkill(21110006,0,20);
		cm.teachSkill(21110007,0,20);
		cm.teachSkill(21110008,0,20);
		cm.teachSkill(21111001,0,20);
		cm.teachSkill(21111005,0,20);
		cm.teachSkill(21120001,0,30);
		cm.teachSkill(21120002,0,30);
		cm.teachSkill(21120004,0,30);
		cm.teachSkill(21120005,0,30);
		cm.teachSkill(21120006,0,30);
		cm.teachSkill(21120007,0,30);
		cm.teachSkill(21120009,0,30);
		cm.teachSkill(21120010,0,30);
		cm.teachSkill(21121000,0,30);
		cm.teachSkill(21121003,0,30);
		cm.teachSkill(21121008,0,5);
		cm.AranSkillEnd();
		cm.sendOk("You have maxed your Aran Mastery! Please be note that never add any skill point into hidden skills!");
		cm.dispose();
	} else {
		cm.sendOk("You have already maxed your mastery!");
		cm.dispose();
	}
}
} else if (selection == 1) {
	if (cm.getAranPoint() < 1 && cm.getJobId() < 1100) {
		cm.getPlayer().maxMastery();
		cm.AranSkillEnd();
		cm.sendOk("You have maxed your Avenger Mastery!");
		cm.dispose();
	} else {
		cm.sendOk("You have already maxed your mastery!");
		cm.dispose();
	}
} else if (selection == 2) {
	if (cm.getAranPoint() < 1 && cm.getJobId() > 1099 && cm.getJobId() < 2000) {
		cm.teachSkill(10001004,1,1);
		cm.teachSkill(11110000,0,20); //Start of Soul Master
		cm.teachSkill(11110005,0,20);
		cm.teachSkill(11111001,0,20);
		cm.teachSkill(11111002,0,20);
		cm.teachSkill(11111003,0,20);
		cm.teachSkill(11111004,0,30);
		cm.teachSkill(11111006,0,30);
		cm.teachSkill(11111007,0,20); //End of Soul Master
		cm.teachSkill(12110000,0,20); //Start of Blaze Wizard
		cm.teachSkill(12110001,0,20);
		cm.teachSkill(12111002,0,20);
		cm.teachSkill(12111003,0,20);
		cm.teachSkill(12111004,0,20);
		cm.teachSkill(12111005,0,30);
		cm.teachSkill(12111006,0,30); //End of Blaze Wizard
		cm.teachSkill(13110003,0,20); //Start of Wind Breaker
		cm.teachSkill(13111000,0,20);
		cm.teachSkill(13111001,0,30);
		cm.teachSkill(13111002,0,20);
		cm.teachSkill(13111004,0,20);
		cm.teachSkill(13111005,0,10);
		cm.teachSkill(13111006,0,20);
		cm.teachSkill(13111007,0,20); //End of Wind Breaker
		cm.teachSkill(14110003,0,20); //Start of Night Walker
		cm.teachSkill(14110004,0,20);
		cm.teachSkill(14111000,0,30);
		cm.teachSkill(14111001,0,20);
		cm.teachSkill(14111002,0,30);
		cm.teachSkill(14111005,0,20);
		cm.teachSkill(14111006,0,30); // End of Night Walker
		cm.teachSkill(15110000,0,20); //Start of Striker
		cm.teachSkill(15111001,0,20);
		cm.teachSkill(15111002,0,10);
		cm.teachSkill(15111003,0,20);
		cm.teachSkill(15111004,0,20);
		cm.teachSkill(15111005,0,20);
		cm.teachSkill(15111006,0,20);
		cm.teachSkill(15111007,0,30); //End of Striker
		cm.AranSkillEnd();
		cm.sendOk("You have maxed your Cygnus Knight Mastery!");
		cm.dispose();
	} else {
		cm.sendOk("You have already maxed your mastery!");
		cm.dispose();
	}
} else if (selection == 3) {
	cm.sendOk("Come back when you need me!");
	cm.dispose();
	}
}
}

Shawn, whats wrong with my script eh? O_O It make me log off everytime I click on the NPC. (Note : I am running v83~)
 
bleh....
Loyal Member
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,129
Re: Learning NPCs, Start to Finish

Code:
var status = 0;


function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
		cm.sendSimple("Hey #b#h ##k, I am here to max your mastery! Please select your job to max : \r\n#L0##rI AM ARAN!#l#k\r\n#L1##rI AM AVENGER!#l#k\r\n#L2##rI AM CYGNUS KNIGHT!#l#k\r\n#L3##rSorry I don't need max mastery!#l#k");
	if (selection == 0) {
	if (cm.getAranPoint() < 1 && cm.getJobId() > 1999) {
		cm.teachSkill(20001004,1,1);
		cm.teachSkill(21000000,0,10);
		cm.teachSkill(21000002,0,20);
		cm.teachSkill(21001001,0,15);
		cm.teachSkill(21001003,0,20);
		cm.teachSkill(21100000,0,20);
		cm.teachSkill(21100001,0,20);
		cm.teachSkill(21100002,0,30);
		cm.teachSkill(21100004,0,20);
		cm.teachSkill(21100005,0,20);
		cm.teachSkill(21101003,0,20);
		cm.teachSkill(21110000,0,20);
		cm.teachSkill(21110002,0,20);
		cm.teachSkill(21110003,0,30);
		cm.teachSkill(21110004,0,30);
		cm.teachSkill(21110006,0,20);
		cm.teachSkill(21110007,0,20);
		cm.teachSkill(21110008,0,20);
		cm.teachSkill(21111001,0,20);
		cm.teachSkill(21111005,0,20);
		cm.teachSkill(21120001,0,30);
		cm.teachSkill(21120002,0,30);
		cm.teachSkill(21120004,0,30);
		cm.teachSkill(21120005,0,30);
		cm.teachSkill(21120006,0,30);
		cm.teachSkill(21120007,0,30);
		cm.teachSkill(21120009,0,30);
		cm.teachSkill(21120010,0,30);
		cm.teachSkill(21121000,0,30);
		cm.teachSkill(21121003,0,30);
		cm.teachSkill(21121008,0,5);
		cm.AranSkillEnd();
		cm.sendOk("You have maxed your Aran Mastery! Please be note that never add any skill point into hidden skills!");
		cm.dispose();
	} else {
		cm.sendOk("You have already maxed your mastery!");
		cm.dispose();
	}
}
} else if (selection == 1) {
	if (cm.getAranPoint() < 1 && cm.getJobId() < 1100) {
		cm.getPlayer().maxMastery();
		cm.AranSkillEnd();
		cm.sendOk("You have maxed your Avenger Mastery!");
		cm.dispose();
	} else {
		cm.sendOk("You have already maxed your mastery!");
		cm.dispose();
	}
} else if (selection == 2) {
	if (cm.getAranPoint() < 1 && cm.getJobId() > 1099 && cm.getJobId() < 2000) {
		cm.teachSkill(10001004,1,1);
		cm.teachSkill(11110000,0,20); //Start of Soul Master
		cm.teachSkill(11110005,0,20);
		cm.teachSkill(11111001,0,20);
		cm.teachSkill(11111002,0,20);
		cm.teachSkill(11111003,0,20);
		cm.teachSkill(11111004,0,30);
		cm.teachSkill(11111006,0,30);
		cm.teachSkill(11111007,0,20); //End of Soul Master
		cm.teachSkill(12110000,0,20); //Start of Blaze Wizard
		cm.teachSkill(12110001,0,20);
		cm.teachSkill(12111002,0,20);
		cm.teachSkill(12111003,0,20);
		cm.teachSkill(12111004,0,20);
		cm.teachSkill(12111005,0,30);
		cm.teachSkill(12111006,0,30); //End of Blaze Wizard
		cm.teachSkill(13110003,0,20); //Start of Wind Breaker
		cm.teachSkill(13111000,0,20);
		cm.teachSkill(13111001,0,30);
		cm.teachSkill(13111002,0,20);
		cm.teachSkill(13111004,0,20);
		cm.teachSkill(13111005,0,10);
		cm.teachSkill(13111006,0,20);
		cm.teachSkill(13111007,0,20); //End of Wind Breaker
		cm.teachSkill(14110003,0,20); //Start of Night Walker
		cm.teachSkill(14110004,0,20);
		cm.teachSkill(14111000,0,30);
		cm.teachSkill(14111001,0,20);
		cm.teachSkill(14111002,0,30);
		cm.teachSkill(14111005,0,20);
		cm.teachSkill(14111006,0,30); // End of Night Walker
		cm.teachSkill(15110000,0,20); //Start of Striker
		cm.teachSkill(15111001,0,20);
		cm.teachSkill(15111002,0,10);
		cm.teachSkill(15111003,0,20);
		cm.teachSkill(15111004,0,20);
		cm.teachSkill(15111005,0,20);
		cm.teachSkill(15111006,0,20);
		cm.teachSkill(15111007,0,30); //End of Striker
		cm.AranSkillEnd();
		cm.sendOk("You have maxed your Cygnus Knight Mastery!");
		cm.dispose();
	} else {
		cm.sendOk("You have already maxed your mastery!");
		cm.dispose();
	}
} else if (selection == 3) {
	cm.sendOk("Come back when you need me!");
	cm.dispose();
	}
}
}

Shawn, whats wrong with my script eh? O_O It make me log off everytime I click on the NPC. (Note : I am running v83~)

PHP:
function start() {
	cm.sendSimple("Hey #b#h ##k, I am here to max your mastery! Please select your job to max : \r\n#L0##rI AM ARAN!#l#k\r\n#L1##rI AM AVENGER!#l#k\r\n#L2##rI AM CYGNUS KNIGHT!#l#k\r\n#L3##rSorry I don't need max mastery!#l#k");
}

function action(m,t,s) {
    if (m < 1) {
        cm.dispose();
		return;
    }else{
		if (s == 0) {
			if (cm.getAranPoint() < 1 && cm.getJobId() >= 2000) {
				cm.teachSkill(20001004,1,1);
				cm.teachSkill(21000000,10,10);
				cm.teachSkill(21000002,20,20);
				cm.teachSkill(21001001,15,15);
				cm.teachSkill(21001003,20,20);
				cm.teachSkill(21100000,20,20);
				cm.teachSkill(21100001,20,20);
				cm.teachSkill(21100002,30,30);
				cm.teachSkill(21100004,20,20);
				cm.teachSkill(21100005,20,20);
				cm.teachSkill(21101003,20,20);
				cm.teachSkill(21110000,20,20);
				cm.teachSkill(21110002,20,20);
				cm.teachSkill(21110003,30,30);
				cm.teachSkill(21110004,30,30);
				cm.teachSkill(21110006,20,20);
				cm.teachSkill(21110007,20,20);
				cm.teachSkill(21110008,20,20);
				cm.teachSkill(21111001,20,20);
				cm.teachSkill(21111005,20,20);
				cm.teachSkill(21120001,30,30);
				cm.teachSkill(21120002,30,30);
				cm.teachSkill(21120004,30,30);
				cm.teachSkill(21120005,30,30);
				cm.teachSkill(21120006,30,30);
				cm.teachSkill(21120007,30,30);
				cm.teachSkill(21120009,30,30);
				cm.teachSkill(21120010,30,30);
				cm.teachSkill(21121000,30,30);
				cm.teachSkill(21121003,30,30);
				cm.teachSkill(21121008,5,5);
				cm.AranSkillEnd();
				cm.sendOk("You have maxed your Aran Mastery! Please be note that never add any skill point into hidden skills!");
			}else{
				cm.sendOk("You have already maxed your mastery!");
			}
			cm.dispose();
		} else if (s == 1) {
			if (cm.getAranPoint() < 1 && cm.getJobId() < 1100) {
				cm.getPlayer().maxMastery();
				cm.AranSkillEnd();
				cm.sendOk("You have maxed your Avenger Mastery!");
			}else{
				cm.sendOk("You have already maxed your mastery!");
			}
			cm.dispose();
		} else if (s == 2) {
			if (cm.getAranPoint() < 1 && cm.getJobId() > 1099 && cm.getJobId() < 2000) {
				cm.teachSkill(10001004,1,1);
				cm.teachSkill(11110000,20,20); //Start of Soul Master
				cm.teachSkill(11110005,20,20);
				cm.teachSkill(11111001,20,20);
				cm.teachSkill(11111002,20,20);
				cm.teachSkill(11111003,20,20);
				cm.teachSkill(11111004,30,30);
				cm.teachSkill(11111006,30,30);
				cm.teachSkill(11111007,20,20); //End of Soul Master
				cm.teachSkill(12110000,20,20); //Start of Blaze Wizard
				cm.teachSkill(12110001,20,20);
				cm.teachSkill(12111002,20,20);
				cm.teachSkill(12111003,20,20);
				cm.teachSkill(12111004,20,20);
				cm.teachSkill(12111005,30,30);
				cm.teachSkill(12111006,30,30); //End of Blaze Wizard
				cm.teachSkill(13110003,20,20); //Start of Wind Breaker
				cm.teachSkill(13111000,20,20);
				cm.teachSkill(13111001,30,30);
				cm.teachSkill(13111002,20,20);
				cm.teachSkill(13111004,20,20);
				cm.teachSkill(13111005,10,10);
				cm.teachSkill(13111006,20,20);
				cm.teachSkill(13111007,20,20); //End of Wind Breaker
				cm.teachSkill(14110003,20,20); //Start of Night Walker
				cm.teachSkill(14110004,20,20);
				cm.teachSkill(14111000,30,30);
				cm.teachSkill(14111001,20,20);
				cm.teachSkill(14111002,30,30);
				cm.teachSkill(14111005,20,20);
				cm.teachSkill(14111006,30,30); // End of Night Walker
				cm.teachSkill(15110000,20,20); //Start of Striker
				cm.teachSkill(15111001,20,20);
				cm.teachSkill(15111002,10,10);
				cm.teachSkill(15111003,20,20);
				cm.teachSkill(15111004,20,20);
				cm.teachSkill(15111005,20,20);
				cm.teachSkill(15111006,20,20);
				cm.teachSkill(15111007,30,30); //End of Striker
				cm.AranSkillEnd();
				cm.sendOk("You have maxed your Cygnus Knight Mastery!");
			}else{
				cm.sendOk("You have already maxed your mastery!");
			}
			cm.dispose();
		} else if (s == 3) {
			cm.sendOk("Come back when you need me!");
			cm.dispose();
		}
	}
}

There's a few methods I'm curious about... Can you please post these methods?

PHP:
cm.getPlayer().maxMastery();
cm.AranSkillEnd();

Also, for future notice, this method here...

PHP:
cm.teachSkill(21000000,10,10);

Is used like this...

PHP:
cm.teachSkill(SkillId,DesiredLevel,MaxPossibleLevel);

The way you had it set, it would have set the skill levels to 0, and prevented players from adding points into the skills.
 
Junior Spellweaver
Joined
Sep 13, 2009
Messages
116
Reaction score
20
Re: Learning NPCs, Start to Finish

@Shawn

method of cm.getPlayer().maxMastery();
Code:
    public void maxMastery() {
        for (MapleData skill_ : mdp.getData("Skill.img").getChildren()) {
            try {
                ISkill skill = SkillFactory.getSkill(Integer.parseInt(skill_.getName()));
                if (skill.getId() / 10000000 == job.getId() / 1000 && getSkillLevel(skill) < 1 && (skill.isFourthJob() || skill.getId() / 10000000 == 2 || (skill.getId() / 10000000 == 1 && skill.getId() / 10000 % 10 == 1))) {
                    changeSkillLevel(skill, 0, Math.min(30, skill.getMaxLevel()));
                }
            } catch (NumberFormatException nfe) {
                break;
            } catch (NullPointerException npe) {
                continue;
            }
        }
    }

And the AranSkillEnd() is actually adding 1 AranPoint and saveToDB combine together. So while AranPoint < 1, mean 0, they can use the NPC, in other word, when they have 1 point, they can't use this npc anymore. This is to prevent they click the NPC again and bring their skill back to 0.

Btw, I put 0 because I am going GMS-like. >< Thanks anyway ^^
 
Newbie Spellweaver
Joined
Nov 5, 2009
Messages
64
Reaction score
1
Re: Learning NPCs, Start to Finish

can u please make a download link for ur Tutorials as *.txt fileS?
 
Newbie Spellweaver
Joined
Nov 5, 2009
Messages
64
Reaction score
1
Re: Learning NPCs, Start to Finish

thanks, where i may find all commands?
 
bleh....
Loyal Member
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,129
Re: Learning NPCs, Start to Finish

What commands? The ones you'd use in the scripts? scripting\AbstractPlayerInteraction.java, scripting\NPCConversationManager.java, and some in client\MapleCharacter.java.
 
Initiate Mage
Joined
Jan 31, 2011
Messages
4
Reaction score
0
Of what source is this guide ( i like to have it the same y'know so i have no mistakes/confusion )
 
Junior Spellweaver
Joined
Jul 26, 2008
Messages
161
Reaction score
51
Of what source is this guide ( i like to have it the same y'know so i have no mistakes/confusion )

When you script NPCs, the source that you use doesn't really matter. Though, the functions (found mostly in MapleCharacter.java or NPCConversationManager.java) differ from source to source.
 
Initiate Mage
Joined
Jan 31, 2011
Messages
4
Reaction score
0
Lolz nice signature =D

What i ment was like what sources use the functions used in here cuz my MoopleDEV source uses diff things...
 
Initiate Mage
Joined
Jan 29, 2009
Messages
3
Reaction score
0
omg, you are so awesome. This guide really really teach me so much!
"Give a man a fish and he will eat it for a day. Teach a man how to fish and he will eat it for life." Thank you so much!
 
Initiate Mage
Joined
Mar 25, 2009
Messages
2
Reaction score
0
at Class 3 Lesson 1 there is (item = [4000313, 4001129, 4001126];) shouldn't it be (VAR item = [4000313, 4001129, 4001126]; )
 
bleh....
Loyal Member
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,129
at Class 3 Lesson 1 there is (item = [4000313, 4001129, 4001126];) shouldn't it be (VAR item = [4000313, 4001129, 4001126]; )

Doesn't have to be because it's a global variable, similar to status.
 
Newbie Spellweaver
Joined
Sep 9, 2010
Messages
9
Reaction score
0
I have this script here and for some reason it will not add to my NX.. Can you help me out?

PHP:
 else if (selection == 6) {
                if (cm.haveItem(4032056, 2)) { 
			  cm.sendOk ("Here you go. Win some more and come back next time.");
			  cm.gainItem(4032056, -2);
			  cm.gainItem(1102181, 1); //Stirgeman's Cloak of Williness
			  cm.gainItem(1092052, 1); //Black Phoenix Shield
			  cm.modifyNX(5000, 3); //5,000 NX
                } else {
			  cm.sendOk ("Sorry, you don't have enough #rMagic Crystal#k.");
			  cm.dispose();
 
Status
Not open for further replies.
Back
Top