Newbie Spellweaver
- Joined
- Mar 23, 2008
- Messages
- 58
- Reaction score
- 0
First off, Credits:
credits to toxicwind for the checkhasItem function, and also for the getItemAmount function -> http://forum.ragezone.com/f427/release-all-teleporter-npc-s-globalms-scripts-version-3-released-381575/#post3273835
credits to oung for his 1st and 2nd job npc scripts because I started out from those -> http://forum.ragezone.com/f427/release-1st-2nd-3rd-4th-job-npc-script-rev007-fixed-add-screenshots-381124/#post3270560
credits to reiyhn for the setsp and getsp functions -> http://forum.ragezone.com/f427/release-stat-reset-clean-1st-job-npcs-380931/#post3269318
These npcs work like the ones in GMS where at level 30 you need to take a letter to the 2nd job instructor and collect dark marbles.
You might have to add the dark marble drop(its id is 4031013) for these monsters: Curse Eye 2, Horned Mushroom 2, Fire Boar 2, Lupin 2, Zombie Mushroom 2, Cold Eye 2, and Blue Mushroom 2,(their ids are 9000001, 9000002, 9000100, 9000101, 9000201, 9000300, and 9000301).
Includes
NPCsScripts.h(add the ones you dont already have):
in whichever .cpp you use for npcs:
Athena
2nd Job Instructor-Bowman
Dances with Balrogs
2nd Job Instructor-Warrior
Dark Lord
2nd Job Instructor-Thief
Grendel the Really Old
2nd Job Instructor-Magician
NPCs.cpp
add this at the bottom:
and add this:
above this:
NPCs.h
add this:
below this:
and add this:
below this:
Inventory.cpp
add this at the bottom:
Inventory.h
add this:
below this:
I've tested them all and they worked for me, if you have any errors feel free to post them.
credits to toxicwind for the checkhasItem function, and also for the getItemAmount function -> http://forum.ragezone.com/f427/release-all-teleporter-npc-s-globalms-scripts-version-3-released-381575/#post3273835
credits to oung for his 1st and 2nd job npc scripts because I started out from those -> http://forum.ragezone.com/f427/release-1st-2nd-3rd-4th-job-npc-script-rev007-fixed-add-screenshots-381124/#post3270560
credits to reiyhn for the setsp and getsp functions -> http://forum.ragezone.com/f427/release-stat-reset-clean-1st-job-npcs-380931/#post3269318
These npcs work like the ones in GMS where at level 30 you need to take a letter to the 2nd job instructor and collect dark marbles.
You might have to add the dark marble drop(its id is 4031013) for these monsters: Curse Eye 2, Horned Mushroom 2, Fire Boar 2, Lupin 2, Zombie Mushroom 2, Cold Eye 2, and Blue Mushroom 2,(their ids are 9000001, 9000002, 9000100, 9000101, 9000201, 9000300, and 9000301).
Includes
Code:
#include "NPCs.h"
#include "Player.h"
#include "NPCsScripts.h"
#include "Inventory.h"
#include "Players.h"
#include "PlayersPacket.h"
NPCsScripts.h(add the ones you dont already have):
Code:
//1st Job Npcs
case 1012100: npc_1012100(npc); break;
case 1052001: npc_1052001(npc); break;
case 1032001: npc_1032001(npc); break;
case 1022000: npc_1022000(npc); break;
//2nd Job Npcs
case 1072000: npc_1072000(npc); break;
case 1072001: npc_1072001(npc); break;
case 1072002: npc_1072002(npc); break;
case 1072003: npc_1072003(npc); break;
//2nd Job Dungeon Npcs
case 1072006: npc_1072006(npc); break;
case 1072004: npc_1072004(npc); break;
case 1072005: npc_1072005(npc); break;
case 1072007: npc_1072007(npc); break;
Code:
//1st Job Npcs
static void npc_1052001(NPC* npc);
static void npc_1012100(NPC* npc);
static void npc_1032001(NPC* npc);
static void npc_1022000(NPC* npc);
//2nd Job Npcs
static void npc_1072000(NPC* npc);
static void npc_1072001(NPC* npc);
static void npc_1072002(NPC* npc);
static void npc_1072003(NPC* npc);
//2nd Job Dungeon Npcs
static void npc_1072006(NPC* npc);
static void npc_1072004(NPC* npc);
static void npc_1072005(NPC* npc);
static void npc_1072007(NPC* npc);
in whichever .cpp you use for npcs:
Athena
Code:
//Athena Pierce
void NPCsScripts::npc_1012100(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(player->getJob() == 000){
if(player->getLevel() >= 10 && player->getDex() >= 25){
npc->addText("Would you like to become an Archer?");
state = 1;
npc->sendYesNo();
}
else{
npc->addText("I'm sorry but you're too weak at the moment.");
npc->sendOK();
npc->end();
}
}
if(player->getJob() == 300 && player->getLevel() >= 30){
if(npc->getItemAmount(4031010) == 0){
if(npc->checkhasItem(player, 4031012)){
npc->addText("I knew the test wouldn't be a problem for you. Are you ready to choose your next path?");
npc->sendYesNo();
}
else{
npc->addText("You have improved significantly. Would you like to take the second job test?");
state = 1;
npc->sendYesNo();
}
}
else{
npc->addText("Please come back after you have passed the test.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("How goes your training?");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
if(npc->getSelected() == YES){
if(player->getLevel() == 10){
player->setJob(300);
npc->addText("You are now an Archer.");
npc->setSP(player->getSp() + 1);
npc->sendOK();
npc->end();
}
else if(player->getLevel() >= 30){
if(npc->getItemAmount(4031010) == 0){
if(npc->getItemAmount(4031012) == 1){
npc->addText("Choose your path. \r\n#L0#Hunter#l\r\n#L1#Crossbowman#l");
npc->sendSimple();
}
else{
npc->addText("Very well, I will give you my recommendation letter. Take it to my assistant and she will give you your next task.");
npc->sendOK();
npc->end();
npc->giveItem(4031010, 1);
}
}
}
}
else{
npc->addText("Hmm.");
npc->sendOK();
npc->end();
}
}
else if(state == 2){
int type = npc->getSelected();
npc->setVariable("type", type);
if(type == 0){
npc->giveItem(4031012, -1);
player->setJob(310);
npc->setSP(player->getSp() + 1);
npc->addText("You are now a Hunter, nothing escapes your bow.");
npc->sendOK();
npc->end();
}
else if(type == 1){
npc->giveItem(4031012, -1);
player->setJob(320);
npc->setSP(player->getSp() + 1);
npc->addText("You are now a Sniper, extremely accurate and deadly.");
npc->sendOK();
npc->end();
}
}
}
2nd Job Instructor-Bowman
Code:
//2nd Job Instructor-Bowman
void NPCsScripts::npc_1072002(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(player->getJob() == 300){
if(player->getLevel() >= 30){
if(npc->getItemAmount(4031012) == 0){
if(npc->checkhasItem(player, 4031010)){
npc->addText("Ah yes this is Athena's handwriting. She must have great faith in you. So are you ready to take the test?");
state = 1;
npc->sendYesNo();
}
else{
npc->addText("You can't take the test without a recommendation.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("What are you waiting for? Take that medal to Athena.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("You are too weak to advance. Come back when you are at least level 30.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("Wonderful day isn't it?");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
if(npc->getSelected() == YES){
npc->addText("Very well. Let the test commence.");
npc->giveItem(4031010, -1);
npc->teleport(108000100);
npc->end();
}
else{
npc->addText("I see. Come back when you are ready to take the test.");
npc->sendOK();
npc->end();
}
}
}
//Bowman dungeon npc
void NPCsScripts::npc_1072006(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(npc->getItemAmount(4031013) >= 30){
npc->addText("You are stronger than I thought. I'll give you a medal to show Athena that you have accomplished this feat.");
npc->sendNext();
}
else{
npc->addText("You aren't quite finished yet.");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
npc->giveItem(4031013, - npc->getItemAmount(4031013));
npc->giveItem(4031012, 1);
npc->teleport(106010000);
npc->end();
}
}
Dances with Balrogs
Code:
//Dances with Balrogs
void NPCsScripts::npc_1022000(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(player->getJob() == 000){
if(player->getLevel() >= 10 && player->getStr() >= 35){
npc->addText("Welcome. Have you come to become a Swordsman?");
state = 1;
npc->sendYesNo();
}
else{
npc->addText("You're too weak. Come back when you're at least level 10 and have a minimum of 35 str.");
npc->sendOK();
npc->end();
}
}
if(player->getJob() == 100 && player->getLevel() >= 30){
if(npc->getItemAmount(4031008) == 0){
if(npc->checkhasItem(player, 4031012)){
npc->addText("I'm glad to see that you passed the test. Would you like to choose your next path now?");
npc->sendYesNo();
}
else{
npc->addText("I see that you're a lot stronger than you were when you first came here. Would you like to become even more powerful?");
state = 1;
npc->sendYesNo();
}
}
else{
npc->addText("There are no shortcuts, you must pass the test or I won't help you.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("Remember, strength is your friend.");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
if(npc->getSelected() == YES){
if(player->getLevel() == 10){
player->setJob(100);
npc->addText("You now have some understanding of how to fight. It is up to you to train and increase your power.");
npc->setSP(player->getSp() + 1);
npc->sendOK();
npc->end();
}
else if(player->getLevel() >= 30){
if(npc->getItemAmount(4031008) == 0){
if(npc->getItemAmount(4031012) == 1){
npc->addText("Choose your path. \r\n#L0#Fighter#l\r\n#L1#Page#l\r\n#L2#Spearman#l");
npc->sendSimple();
}
else{
npc->addText("If you're sure that you're ready, then take this letter to my assistant so that he may test you. Good luck young warrior.");
npc->sendOK();
npc->end();
npc->giveItem(4031008, 1);
}
}
}
}
else{
npc->addText("Very well.");
npc->sendOK();
npc->end();
}
}
else if(state == 2){
int type = npc->getSelected();
npc->setVariable("type", type);
if(type == 0){
npc->giveItem(4031012, -1);
player->setJob(110);
npc->setSP(player->getSp() + 1);
npc->addText("You are now a Fighter, with the ability to masterfully wield swords and axes no one would dare challenge you.");
npc->sendOK();
npc->end();
}
else if(type == 1){
npc->giveItem(4031012, -1);
player->setJob(120);
npc->setSP(player->getSp() + 1);
npc->addText("You are now an Page, your range of elemental attacks can take almost any enemy by surprise.");
npc->sendOK();
npc->end();
}
else if(type == 2){
npc->giveItem(4031012, -1);
player->setJob(130);
npc->setSP(player->getSp() + 1);
npc->addText("You are now a Spearman, easily capable of keeping any enemy at bay until you are ready to finish them off.");
npc->sendOK();
npc->end();
}
}
}
2nd Job Instructor-Warrior
Code:
//2nd Job Instructor-Warrior
void NPCsScripts::npc_1072000(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(player->getJob() == 100){
if(player->getLevel() >= 30){
if(npc->getItemAmount(4031012) == 0){
if(npc->checkhasItem(player, 4031008)){
npc->addText("I see, so Dances with Balrogs wishes for me to test you. Well then, are you ready to begin the test?");
state = 1;
npc->sendYesNo();
}
else{
npc->addText("You must have a recommendation from Dances with Balrogs to take this test.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("You're still here? Hurry up and take that to Dances with Balrogs.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("You are too weak to advance. Come back when you are at least level 30.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("Hello traveller.");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
if(npc->getSelected() == YES){
npc->addText("Very well. Let the test commence.");
npc->giveItem(4031008, -1);
npc->teleport(108000300);
npc->end();
}
else{
npc->addText("I see. Come back when you are ready to take the test.");
npc->sendOK();
npc->end();
}
}
}
//Warrior dungeon npc
void NPCsScripts::npc_1072004(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(npc->getItemAmount(4031013) >= 30){
npc->addText("You are stronger than I thought. I'll give you a medal to show Dances with Balrogs that you have passed this test.");
npc->sendNext();
}
else{
npc->addText("You aren't quite finished yet.");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
npc->giveItem(4031013, - npc->getItemAmount(4031013));
npc->giveItem(4031012, 1);
npc->teleport(102020300);
npc->end();
}
}
Dark Lord
Code:
//Dark Lord
void NPCsScripts::npc_1052001(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(player->getJob() == 000){
if(player->getLevel() >= 10 && player->getDex() >= 25){
npc->addText("Are you here to become a Rogue and be my minion?");
state = 1;
npc->sendYesNo();
}
else{
npc->addText("You're too weak, come back when you're at least level 10 and have a minimum of 25 dex.");
npc->sendOK();
npc->end();
}
}
if(player->getJob() == 400 && player->getLevel() >= 30){
if(npc->getItemAmount(4031011) == 0){
if(npc->checkhasItem(player, 4031012)){
npc->addText("I see you survived. Very well, would you like to choose your next path?");
npc->sendYesNo();
}
else{
npc->addText("You're a lot stronger than when I first saw you. Do you wish to become even stronger?");
state = 1;
npc->sendYesNo();
}
}
else{
npc->addText("Come back when you've completed the test.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("Steal from the rich and keep it for yourself.");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
if(npc->getSelected() == YES){
if(player->getLevel() == 10){
player->setJob(400);
npc->addText("You are now an Rogue. The first step in becoming a great thief like me.");
npc->setSP(player->getSp() + 1);
npc->sendOK();
npc->end();
}
else if(player->getLevel() >= 30){
if(npc->getItemAmount(4031011) == 0){
if(npc->getItemAmount(4031012) == 1){
npc->addText("Choose your path. \r\n#L0#Assassin#l\r\n#L1#Bandit#l");
npc->sendSimple();
}
else{
npc->addText("Then take this letter to my assistant and he'll test you to see if you're worthy.");
npc->sendOK();
npc->end();
npc->giveItem(4031011, 1);
}
}
}
}
else{
npc->addText("Quit wasting my time.");
npc->sendOK();
npc->end();
}
}
else if(state == 2){
int type = npc->getSelected();
npc->setVariable("type", type);
if(type == 0){
npc->giveItem(4031012, -1);
player->setJob(410);
npc->setSP(player->getSp() + 1);
npc->addText("You are now an Assassin, using your mighty arm you throw stars into the eyes of your enemies.");
npc->sendOK();
npc->end();
}
else if(type == 1){
npc->giveItem(4031012, -1);
player->setJob(420);
npc->setSP(player->getSp() + 1);
npc->addText("You are now a Bandit, your dagger stabs into your enemies before they even know what hit them.");
npc->sendOK();
npc->end();
}
}
}
2nd Job Instructor-Thief
Code:
//2nd Job Instructor-Thief
void NPCsScripts::npc_1072003(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(player->getJob() == 400){
if(player->getLevel() >= 30){
if(npc->getItemAmount(4031012) == 0){
if(npc->checkhasItem(player, 4031011)){
npc->addText("Hmm. This is the seal of master Dark Lord. Very well, are you ready to be tested?");
state = 1;
npc->sendYesNo();
}
else{
npc->addText("You can not take this test without a recommendation from master Dark Lord.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("Quit bothering me and take that to master Dark Lord.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("You are too weak. Come back when you are at least level 30.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("What do you want?");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
if(npc->getSelected() == YES){
npc->addText("Very well. Let the test commence.");
npc->giveItem(4031011, -1);
npc->teleport(108000400);
npc->end();
}
else{
npc->addText("I see. Come back when you are ready to take the test.");
npc->sendOK();
npc->end();
}
}
}
//Thief dungeon npc
void NPCsScripts::npc_1072007(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(npc->getItemAmount(4031013) >= 30){
npc->addText("You are stronger than I thought. I'll give you a medal to show master Dark Lord that you have passed.");
npc->sendNext();
}
else{
npc->addText("You aren't quite finished yet.");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
npc->giveItem(4031013, - npc->getItemAmount(4031013));
npc->giveItem(4031012, 1);
npc->teleport(102040000);
npc->end();
}
}
Grendel the Really Old
Code:
//Grendel the Really Old
void NPCsScripts::npc_1032001(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(player->getJob() == 000){
if(player->getLevel() >= 8 && player->getInt() >= 25){
npc->addText("Hello young adventurer. Do you wish to harness the power of magic?");
state = 1;
npc->sendYesNo();
}
else{
npc->addText("You lack the focus required to use magic. Come back when you're at least level 8 and have a minimum of 25 int.");
npc->sendOK();
npc->end();
}
}
if(player->getJob() == 200 && player->getLevel() >= 30){
if(npc->getItemAmount(4031009) == 0){
if(npc->checkhasItem(player, 4031012)){
npc->addText("I see you survived. Very well, would you like to choose your next path?");
npc->sendYesNo();
}
else{
npc->addText("You've increased your magic power considerably. Would you like to increase it even further?");
state = 1;
npc->sendYesNo();
}
}
else{
npc->addText("Finish the test and then I will help you to become more powerful.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("Always remained focused when using magic.");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
if(npc->getSelected() == YES){
if(player->getLevel() == 10){
player->setJob(200);
npc->addText("Your magic power has been awakened. It is up to you to improve upon it.");
npc->setSP(player->getSp() + 1);
npc->sendOK();
npc->end();
}
else if(player->getLevel() >= 30){
if(npc->getItemAmount(4031009) == 0){
if(npc->getItemAmount(4031012) == 1){
npc->addText("Choose your path. \r\n#L0#Fire/Poison Wizard#l\r\n#L1#Ice/Lightning Wizard#l\r\n#L2#Cleric#l");
npc->sendSimple();
}
else{
npc->addText("If you truly wish to become more powerful then you must first be tested. Take this letter to my assistant and they will test your power.");
npc->sendOK();
npc->end();
npc->giveItem(4031009, 1);
}
}
}
}
else{
npc->addText("Very well.");
npc->sendOK();
npc->end();
}
}
else if(state == 2){
int type = npc->getSelected();
npc->setVariable("type", type);
if(type == 0){
npc->giveItem(4031012, -1);
player->setJob(210);
npc->setSP(player->getSp() + 1);
npc->addText("You are now a Fire/Poison Wizard, your fire melts steel and your poison can take down giants.");
npc->sendOK();
npc->end();
}
else if(type == 1){
npc->giveItem(4031012, -1);
player->setJob(220);
npc->setSP(player->getSp() + 1);
npc->addText("You are now an Ice/Lightning Wizard, your lightning is more powerful than a thunderstorm and your ice is colder than the arctic.");
npc->sendOK();
npc->end();
}
else if(type == 2){
npc->giveItem(4031012, -1);
player->setJob(230);
npc->setSP(player->getSp() + 1);
npc->addText("You are now a Cleric, you heal the wounds of others and the undead make a habit of avoiding you.");
npc->sendOK();
npc->end();
}
}
}
2nd Job Instructor-Magician
Code:
//2nd Job Instructor-Magician
void NPCsScripts::npc_1072001(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(player->getJob() == 200){
if(player->getLevel() >= 30){
if(npc->getItemAmount(4031012) == 0){
if(npc->checkhasItem(player, 4031009)){
npc->addText("You must be powerful if Grendel sent you. Very well, are you ready?");
state = 1;
npc->sendYesNo();
}
else{
npc->addText("You need a recommendation from Grendel before you can take this test.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("What are you waiting for? Get moving and take that to Grendel.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("You are too weak to advance. Come back when you are at least level 30.");
npc->sendOK();
npc->end();
}
}
else{
npc->addText("Yes?");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
if(npc->getSelected() == YES){
npc->addText("Very well. Let the test commence.");
npc->giveItem(4031009, -1);
npc->teleport(108000200);
npc->end();
}
else{
npc->addText("I see. Come back when you are ready to take the test.");
npc->sendOK();
npc->end();
}
}
}
//Magician dungeon npc
void NPCsScripts::npc_1072005(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(npc->getItemAmount(4031013) >= 30){
npc->addText("You are stronger than I thought. I'll give you a medal to show Grendel that you have passed this test.");
npc->sendNext();
}
else{
npc->addText("You aren't quite finished yet.");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
npc->giveItem(4031013, - npc->getItemAmount(4031013));
npc->giveItem(4031012, 1);
npc->teleport(101020000);
npc->end();
}
}
NPCs.cpp
add this at the bottom:
Code:
int NPC::checkhasItem(Player* player, int item){
return Inventory::hasItem(player, item);
}
int NPC::getItemAmount(int itemid){
return player->inv->getItemAmount(itemid);
}
and add this:
Code:
void NPC::setSP(short sp)
{
player->setSp(sp);
}
above this:
Code:
void NPC::setPlayerHP(short hp){
player->setHP(hp);
}
NPCs.h
add this:
Code:
int checkhasItem(Player* player, int item);
int getItemAmount(int itemid);
below this:
Code:
void giveEXP(int exp);
and add this:
Code:
void setSP(short sp);
below this:
Code:
void setGetText(char* text){
strcpy_s(this->gettext, strlen(text)+1, text);
}
Inventory.cpp
add this at the bottom:
Code:
int Inventory::hasItem(Player* player, int item) {
for(int i=0; i<player->inv->getItemNum(); i++) {
if(player->inv->getItem(i)->id == item){
return 1;
}
}
return 0;
}
Inventory.h
add this:
Code:
static int hasItem(Player* player, int item);
below this:
Code:
static void stopChair(Player* player, unsigned char* packet);
I've tested them all and they worked for me, if you have any errors feel free to post them.
Last edited: