summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/chat.c34
-rw-r--r--src/map/chat.h5
-rw-r--r--src/map/script.c58
3 files changed, 51 insertions, 46 deletions
diff --git a/src/map/chat.c b/src/map/chat.c
index 4c2a001ec..933674db8 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -23,7 +23,7 @@ int chat_triggerevent(struct chat_data *cd); // forward declaration
/// Initializes a chatroom object (common functionality for both pc and npc chatrooms).
/// Returns a chatroom object on success, or NULL on failure.
-static struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev)
+static struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
{
struct chat_data* cd;
nullpo_retr(NULL, bl);
@@ -36,6 +36,9 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl
cd->users = 0;
cd->limit = min(limit, ARRAYLENGTH(cd->usersd));
cd->trigger = trigger;
+ cd->zeny = zeny;
+ cd->minLvl = minLvl;
+ cd->maxLvl = maxLvl;
memset(cd->usersd, 0, sizeof(cd->usersd));
cd->owner = bl;
safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event));
@@ -88,7 +91,7 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char
pc_stop_walking(sd,1);
- cd = chat_createchat(&sd->bl, title, pass, limit, pub, 0, "");
+ cd = chat_createchat(&sd->bl, title, pass, limit, pub, 0, "", 0, 1, MAX_LEVEL);
if( cd )
{
cd->users = 1;
@@ -125,6 +128,22 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
return 0;
}
+ if( sd->status.base_level < cd->minLvl || sd->status.base_level > cd->maxLvl )
+ {
+ if(sd->status.base_level < cd->minLvl)
+ clif_joinchatfail(sd,5);
+ else
+ clif_joinchatfail(sd,6);
+
+ return 0;
+ }
+
+ if( sd->status.zeny < cd->zeny )
+ {
+ clif_joinchatfail(sd,4);
+ return 0;
+ }
+
pc_stop_walking(sd,1);
cd->usersd[cd->users] = sd;
cd->users++;
@@ -299,7 +318,7 @@ int chat_kickchat(struct map_session_data* sd, const char* kickusername)
}
/// Creates a chat room for the npc.
-int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev)
+int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
{
struct chat_data* cd;
nullpo_ret(nd);
@@ -310,7 +329,14 @@ int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool p
return 0;
}
- cd = chat_createchat(&nd->bl, title, "", limit, pub, trigger, ev);
+ if( zeny > MAX_ZENY || maxLvl > MAX_LEVEL )
+ {
+ ShowError("chat_createnpcchat: npc '%s' has a required lvl or amount of zeny over the max limit!\n", nd->exname);
+ return 0;
+ }
+
+ cd = chat_createchat(&nd->bl, title, "", limit, pub, trigger, ev, zeny, minLvl, maxLvl);
+
if( cd )
{
nd->chat_id = cd->bl.id;
diff --git a/src/map/chat.h b/src/map/chat.h
index 569e6cbe8..be3efb513 100644
--- a/src/map/chat.h
+++ b/src/map/chat.h
@@ -17,6 +17,9 @@ struct chat_data {
uint8 users; // current user count
uint8 limit; // join limit
uint8 trigger; // number of users needed to trigger event
+ uint32 zeny; // required zeny to join
+ uint32 minLvl; // minimum base level to join
+ uint32 maxLvl; // maximum base level allowed to join
struct map_session_data* usersd[20];
struct block_list* owner;
char npc_event[50];
@@ -30,7 +33,7 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername)
int chat_changechatstatus(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub);
int chat_kickchat(struct map_session_data* sd, const char* kickusername);
-int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev);
+int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl);
int chat_deletenpcchat(struct npc_data* nd);
int chat_enableevent(struct chat_data* cd);
int chat_disableevent(struct chat_data* cd);
diff --git a/src/map/script.c b/src/map/script.c
index 3cb469ac5..e9e1a51c0 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9262,52 +9262,24 @@ BUILDIN_FUNC(globalmes)
return 0;
}
-/////////////////////////////////////////////////////////////////////
-// NPC waiting room (chat room)
-//
-
-/// Creates a waiting room (chat room) for this npc.
-///
-/// waitingroom "<title>",<limit>,<trigger>,"<event>";
-/// waitingroom "<title>",<limit>,"<event>",<trigger>;
-/// waitingroom "<title>",<limit>,"<event>";
-/// waitingroom "<title>",<limit>;
+/*==========================================
+ * Creates a waiting room (chat room)
+ *------------------------------------------*/
BUILDIN_FUNC(waitingroom)
{
- struct npc_data* nd;
- const char* title;
- const char* ev = "";
- int limit;
- int trigger = 0;
+ struct npc_data* nd;
int pub = 1;
-
- title = script_getstr(st, 2);
- limit = script_getnum(st, 3);
-
- if( script_hasdata(st,5) )
- {
- struct script_data* last = script_getdata(st, 5);
- get_val(st, last);
- if( data_isstring(last) )
- {// ,<trigger>,"<event>"
- trigger = script_getnum(st, 4);
- ev = script_getstr(st, 5);
- }
- else
- {// ,"<event>",<trigger>
- ev = script_getstr(st, 4);
- trigger = script_getnum(st,5);
- }
- }
- else if( script_hasdata(st,4) )
- {// ,"<event>"
- ev = script_getstr(st, 4);
- trigger = limit;
- }
+ const char* title = script_getstr(st, 2);
+ int limit = script_getnum(st, 3);
+ const char* ev = script_hasdata(st,4) ? script_getstr(st,4) : "";
+ int trigger = script_hasdata(st,5) ? script_getnum(st,5) : limit;
+ int zeny = script_hasdata(st,6) ? script_getnum(st,6) : 0;
+ int minLvl = script_hasdata(st,7) ? script_getnum(st,7) : 1;
+ int maxLvl = script_hasdata(st,8) ? script_getnum(st,8) : MAX_LEVEL;
nd = (struct npc_data *)map_id2bl(st->oid);
if( nd != NULL )
- chat_createnpcchat(nd, title, limit, pub, trigger, ev);
+ chat_createnpcchat(nd, title, limit, pub, trigger, ev, zeny, minLvl, maxLvl);
return 0;
}
@@ -9488,9 +9460,13 @@ BUILDIN_FUNC(warpwaitingpc)
return 0;// can't teleport on this map
pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
+ if( cd->zeny )
+ pc_payzeny(sd, cd->zeny);
}
else
pc_setpos(sd, mapindex_name2id(map_name), x, y, CLR_OUTSIGHT);
+ if( cd->zeny )
+ pc_payzeny(sd, cd->zeny);
}
mapreg_setreg(add_str("$@warpwaitingpcnum"), i);
return 0;
@@ -15029,7 +15005,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(skillpointcount,""),
BUILDIN_DEF(changebase,"i?"),
BUILDIN_DEF(changesex,""),
- BUILDIN_DEF(waitingroom,"si??"),
+ BUILDIN_DEF(waitingroom,"si?????"),
BUILDIN_DEF(delwaitingroom,"?"),
BUILDIN_DEF2(waitingroomkickall,"kickwaitingroomall","?"),
BUILDIN_DEF(enablewaitingroomevent,"?"),