Skocz do zawartości

Dołącz do społeczności!

👋 Witaj na MPCForum!

Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

  • ✅ Pełny dostęp do działów i ukrytych treści
  • ✅ Możliwość pisania i odpowiadania w tematach
  • ✅ System prywatnych wiadomości
  • ✅ Zbieranie reputacji i rozwijanie swojego profilu
  • ✅ Członkostwo w jednej z największych społeczności graczy

👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

Zarejestruj się teraz

[TuT] Jak zrobić NPC

Rekomendowane odpowiedzi

Opublikowano

Well, I have seen a few people saying "OMG, Someone give me an example of scripting an NPC!?".

 

Ok, well, here is a simple tutorial on doing so!

 

 

[Files that are going to be edited]

NPCsScripts.h

 

Note:: Online code wrapped around the {code} tags should be added to your NPC,unless you are adding your own code....

 

Let's begin::

 

1.You need to create a new CPP source file ->Cody.cpp

 

2.Ok, In your new NPC file[Which is Cody.cpp] In this tutorial.

Include the following headers

#include "NPCs.h"
#include "NPCsScripts.h"

 

3.Ok, We are getting to the hard part.

We need to declare a new "void" function, derived from class NPCsScripts..

 

We do this by the following

 

void NPCsScripts::npc_2100(NPC* npc){

}

 

 

Now, You may be wondering, where the hell did I get npc_2100?

Easy, that is the NPC's ID.You can find all NPC ID's here.

 

 

It is also located in file "NPCsScripts.h". We will look into that later though.

 

Let's move on.

 

Step 4.We need to declare Integers state and map.

state-> Current State

map-> Game map..

 

We do this by adding

int state = npc->getState();
int map = npc->getPlayerMap();

 

in between

 

void NPCsScripts::npc_2100(NPC* npc){

}

 

Your new code should look something like this...

 

void NPCsScripts::npc_2100(NPC* npc){
int state = npc->getState();
int map = npc->getPlayerMap();
}

 

:).

 

Step5. Now we need to add our Map Checks :).

add

if(npc->getPlayerMap() == 100000000){

}

 

after

 

int state = npc->getState();
int map = npc->getPlayerMap();

 

 

In case you didn't know, the map is defined by it's Id, which in this tutorial is Map ID '100000000'[Henesys].Get Map ID's from here.

 

Ok, lets move on to adding our if(state) commands!

 

Step6. Hmm, This is kinda confusing, but I will get more into detail about this later, for now, just think of this as the npc State. State[0] = Begin Chat with NPC.... State[1] == Selected Yes/No...[Remember, this is not the case, just an example...Look into the code for more details.....]

 

Add your if(state == 0) checks!

 

To do this, add

 

if(state == 0){

}

 

in between

 

if(npc->getPlayerMap() == 100000000){

}

 

Your new code should look like this....

 

void NPCsScripts::npc_2100(NPC* npc){
int state = npc->getState();
int map = npc->getPlayerMap();
if(npc->getPlayerMap() == 100000000){
	if(state == 0){

	}
}

 

We are almost done....With cody.cpp anyways!

 

Now, You just implement what you want cody to do....References at the end of the tutorial....

 

Here is an example...

 

 

#include "NPCs.h"
#include "NPCsScripts.h"

void NPCsScripts::npc_2100(NPC* npc){
int state = npc->getState();
int map = npc->getPlayerMap();
if(npc->getPlayerMap() == 100000000){
	if(state == 0){

		 npc->addText("");//Send Text For Cody To Output
		 npc->sendNext();//Just think of this to enable you to Click "next" button for continuing....
		 npc->addText("Good Bye");
		 npc->sendOK();//Think of this to Enable click "ok" before continuing...
		 npc->end();//You should know what this is.....Quit Talking to NPC...?

	}
}

 

Now, Let's change the NPC ID -> 9200000 <- This is cody's NPC_ID...Can find NPC ID's here.

 

change

 

void NPCsScripts::npc_2100(NPC* npc)

 

to

 

void NPCsScripts::npc_9200000(NPC* npc)

 

Geez, Finally, We can close Cody.cpp.

 

Now, Open NPCsScripts.h

 

Step6. In NPCsScripts.h, you should see these both!

 

switch(npcid){
		case 2100: npc_2100(npc); break;
		case 2101: npc_2101(npc); break;
		case 2020005: npc_2020005(npc); break;
		case 9101001: npc_9101001(npc); break;
		case 9900000: npc_9900000(npc); break;
		default: npc->end(); break;
	}

 

and

 

private:
static void npc_2100(NPC* npc);
static void npc_2101(NPC* npc);
static void npc_2020005(NPC* npc);
static void npc_9101001(NPC* npc);
static void npc_9900000(NPC* npc);

 

or something similar eh?

 

Well, We just need to add decelerations and we are done.

 

Look hard? eh, no the hell it doesn't....

 

Simple add these two to the correct areas.

 

static void npc_9200000(NPC* npc);

 

and

 

case 9900000: npc_9200000(npc); break;

 

It should be obvious as to where these both go, no?

 

Great! Well, we are done with this tutorial for now!

 

Compile and test your new NPC :).

 

 

 

 

Note::

 

Please reply with any ways I can make this thread more understandable/clearer.

English is my fourth language, So I may not have the best english.......

 

 

 

npc Commands

npc->addChar(char cha);
npc->addQuest(int QuestID);
npc->addText(char string);
npc->cend();
npc->end();
npc->endQuest();
npc->getItemNum(int itemid);
npc->getMesos();
npc->getNpcID();
npc->getnum();
npc->getNumber();
npc->getPlayer();
npc->getPlayerEyes();
npc->getPlayerHP();
npc->getPlayerMap();
npc->getSelected();
npc->getState();
npc->getState();
npc->getText();
npc->gettext();
npc->getVariable(char *name);
npc->giveEXP(int exp);
npc->giveItem(int itemid,short amount);
npc->giveMesos(int amount);
npc->isEnd();//bool
npc->isQuest();//bool
npc->isquest();
npc->isStart();//bool
npc->isstart();
npc->npcid();
npc->npcPacket(char type);
npc->player();//More to come....
npc->selected();
npc->sendAcceptDecline();
npc->sendBackNext();
npc->sendOK();
npc->sendBackOK();
npc->sendGetNumber(int def,int min,int max);
npc->sendGetText();
npc->sendOK();
npc->sendNext();
npc->sendSimple();
npc->sendStyle();
npc->sendYesNo();
npc->setGetNumber(int num);
npc->setGetText(char *text);
npc->setIsStart(bool what);
npc->setPlayerHP(short hp);
npc->setSelected(int selected);
npc->setState(int state);
npc->setStyle(int id);
npc->setVariable(char *name,int val);
npc->showShop();
npc->state();
npc->teleport(int mapid);
npc->text();
npc->vars();
npc->~NPC();

 

Enjoy

 

Credits: cPlusPlus @ RaGEZONE

Opublikowano

Sam myślałem nad wstawieniem :P

Dodaj creditsy i będzie kul.

Poza tym, przejrzyste i łatwe do zrozumienia, jak się zna choć trochę angielski.

exModerator MapleStory

Opublikowano

no fajnie nice tylko szkoda ze po angielsku;/

Ja:

Ej wiw3k, jedziemy do czarnobyla?

Wiw3k:

Nieee, bo tam aciek grasuje.

Opublikowano

Więc podam Ci:

Credits: cPlusPlus @ RaGEZONE.

exModerator MapleStory

Opublikowano

Ok fajnie troche juz przez translatora przeszło i cos tam rozumiem :]

Zauważyłam ze niektórzy mają w sygnie ze do priv serva zrobione wszystko jest ale npc : 40% :]

Napewno sie przyda :]

 

Z poważaniem

Kacye

Ja:

Ej wiw3k, jedziemy do czarnobyla?

Wiw3k:

Nieee, bo tam aciek grasuje.

  • 2 tygodnie później...

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Ostatnio przeglądający 0

  • Brak zarejestrowanych użytkowników przeglądających tę stronę.

Konto

Nawigacja

Skonfiguruj powiadomienia push w przeglądarce

Chrome (Android)
  1. Stuknij ikonę kłódki obok paska adresu.
  2. Stuknij Uprawnienia → Powiadomienia.
  3. Dostosuj swoje ustawienie.
Chrome (Komputer)
  1. Kliknij ikonę kłódki na pasku adresu.
  2. Wybierz Ustawienia witryny.
  3. Znajdź Powiadomienia i dostosuj swoje ustawienie.