summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorshennetsind <shennetsind@users.noreply.github.com>2013-10-25 21:11:05 -0700
committershennetsind <shennetsind@users.noreply.github.com>2013-10-25 21:11:05 -0700
commit1ab0017183e910271f4590beee37530fa3ce8ba0 (patch)
tree03ef8eb76a73d498e69e8c7e1160a1015a4c9653 /src/map/script.c
parent5f6f1d66834b8328496c1678f0ce4f90a001b3fb (diff)
parentf7158456d9f6338b38b16f321c9a229fc6547bc0 (diff)
downloadhercules-1ab0017183e910271f4590beee37530fa3ce8ba0.tar.gz
hercules-1ab0017183e910271f4590beee37530fa3ce8ba0.tar.bz2
hercules-1ab0017183e910271f4590beee37530fa3ce8ba0.tar.xz
hercules-1ab0017183e910271f4590beee37530fa3ce8ba0.zip
Merge pull request #202 from kisuka/master
Quest Bubbles (Actually Works Finally)
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c104
1 files changed, 95 insertions, 9 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 826c5ae34..efc3e0264 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -15456,12 +15456,82 @@ BUILDIN(readbook)
Questlog script commands
*******************/
+BUILDIN(questinfo)
+{
+ struct npc_data *nd = map->id2nd(st->oid);
+ int quest, icon, job, color = 0;
+ struct questinfo qi;
+
+ if( nd == NULL || nd->bl.m == -1 )
+ return true;
+
+ quest = script_getnum(st, 2);
+ icon = script_getnum(st, 3);
+
+ #if PACKETVER >= 20120410
+ if(icon < 0 || (icon > 8 && icon != 9999) || icon == 7)
+ icon = 9999; // Default to nothing if icon id is invalid.
+ #else
+ if(icon < 0 || icon > 7)
+ icon = 0;
+ else
+ icon = icon + 1;
+ #endif
+
+ qi.quest_id = quest;
+ qi.icon = (unsigned char)icon;
+ qi.nd = nd;
+
+ if( script_hasdata(st, 4) ) {
+ color = script_getnum(st, 4);
+ if( color < 0 || color > 3 ) {
+ ShowWarning("buildin_questinfo: invalid color '%d', changing to 0\n",color);
+ script->reportfunc(st);
+ color = 0;
+ }
+ qi.color = (unsigned char)color;
+ }
+
+ qi.hasJob = false;
+
+ if(script_hasdata(st, 5)) {
+ job = script_getnum(st, 5);
+
+ if (!pcdb_checkid(job))
+ ShowError("buildin_questinfo: Nonexistant Job Class.\n");
+ else {
+ qi.hasJob = true;
+ qi.job = (unsigned short)job;
+ }
+ }
+
+ map->add_questinfo(nd->bl.m,&qi);
+
+ return true;
+}
+
BUILDIN(setquest)
{
struct map_session_data *sd = script->rid2sd(st);
- nullpo_retr(false,sd);
+ unsigned short i;
+ if (!sd)
+ return false;
+
quest->add(sd, script_getnum(st, 2));
+
+ // If questinfo is set, remove quest bubble once quest is set.
+ for(i = 0; i < map->list[sd->bl.m].qi_count; i++) {
+ struct questinfo *qi = &map->list[sd->bl.m].qi_data[i];
+ if( qi->quest_id == script_getnum(st, 2) ) {
+#if PACKETVER >= 20120410
+ clif->quest_show_event(sd, &qi->nd->bl, 9999, 0);
+#else
+ clif->quest_show_event(sd, &qi->nd->bl, 0, 0);
+#endif
+ }
+ }
+
return true;
}
@@ -15510,17 +15580,32 @@ BUILDIN(checkquest)
BUILDIN(showevent) {
TBL_PC *sd = script->rid2sd(st);
struct npc_data *nd = map->id2nd(st->oid);
- int state, color;
+ int icon, color = 0;
if( sd == NULL || nd == NULL )
return true;
- state = script_getnum(st, 2);
- color = script_getnum(st, 3);
-
- if( color < 0 || color > 3 )
- color = 0; // set default color
+
+ icon = script_getnum(st, 2);
+ if( script_hasdata(st, 3) ) {
+ color = script_getnum(st, 3);
+ if( color < 0 || color > 3 ) {
+ ShowWarning("buildin_showevent: invalid color '%d', changing to 0\n",color);
+ script->reportfunc(st);
+ color = 0;
+ }
+ }
+
+ #if PACKETVER >= 20120410
+ if(icon < 0 || (icon > 8 && icon != 9999) || icon == 7)
+ icon = 9999; // Default to nothing if icon id is invalid.
+ #else
+ if(icon < 0 || icon > 7)
+ icon = 0;
+ else
+ icon = icon + 1;
+ #endif
- clif->quest_show_event(sd, &nd->bl, state, color);
+ clif->quest_show_event(sd, &nd->bl, icon, color);
return true;
}
@@ -18026,12 +18111,13 @@ void script_parse_builtin(void) {
BUILDIN_DEF(useatcmd, "s"),
//Quest Log System [Inkfish]
+ BUILDIN_DEF(questinfo, "ii??"),
BUILDIN_DEF(setquest, "i"),
BUILDIN_DEF(erasequest, "i"),
BUILDIN_DEF(completequest, "i"),
BUILDIN_DEF(checkquest, "i?"),
BUILDIN_DEF(changequest, "ii"),
- BUILDIN_DEF(showevent, "ii"),
+ BUILDIN_DEF(showevent, "i?"),
/**
* hQueue [Ind/Hercules]