00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "game-server/character.hpp"
00022 #include "game-server/npc.hpp"
00023 #include "scripting/script.hpp"
00024
00025 NPC::NPC(const std::string &name, int id, Script *s):
00026 Being(OBJECT_NPC),
00027 mScript(s),
00028 mID(id),
00029 mEnabled(true)
00030 {
00031 setName(name);
00032 }
00033
00034 void NPC::enable(bool enabled)
00035 {
00036 mEnabled = enabled;
00037 }
00038
00039 void NPC::update()
00040 {
00041 if (!mScript || !mEnabled) return;
00042 mScript->prepare("npc_update");
00043 mScript->push(this);
00044 mScript->execute();
00045 }
00046
00047 void NPC::prompt(Character *ch, bool restart)
00048 {
00049 if (!mScript || !mEnabled) return;
00050 mScript->prepare(restart ? "npc_start" : "npc_next");
00051 mScript->push(this);
00052 mScript->push(ch);
00053 mScript->execute();
00054 }
00055
00056 void NPC::select(Character *ch, int v)
00057 {
00058 if (!mScript || !mEnabled) return;
00059 mScript->prepare("npc_choose");
00060 mScript->push(this);
00061 mScript->push(ch);
00062 mScript->push(v);
00063 mScript->execute();
00064 }
00065