summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c146
1 files changed, 128 insertions, 18 deletions
diff --git a/src/map/script.c b/src/map/script.c
index d7a65f554..36f37abb9 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -29,6 +29,7 @@
#include "map/channel.h"
#include "map/chat.h"
#include "map/chrif.h"
+#include "map/clan.h"
#include "map/clif.h"
#include "map/date.h"
#include "map/elemental.h"
@@ -5593,6 +5594,8 @@ int script_reload(void)
itemdb->name_constants();
+ clan->set_constants();
+
sysinfo->vcsrevision_reload();
return 0;
@@ -8627,32 +8630,45 @@ BUILDIN(readparam) {
* 2 : guild_id
* 3 : account_id
* 4 : bg_id
+ * 5 : clan_id
*------------------------------------------*/
BUILDIN(getcharid) {
- int num;
+ int num = script_getnum(st, 2);
struct map_session_data *sd;
-
- num = script_getnum(st,2);
- if( script_hasdata(st,3) )
- sd=map->nick2sd(script_getstr(st,3));
+
+ if (script_hasdata(st, 3))
+ sd = map->nick2sd(script_getstr(st, 3));
else
- sd=script->rid2sd(st);
+ sd = script->rid2sd(st);
- if(sd==NULL) {
- script_pushint(st,0); //return 0, according docs
+ if (sd == NULL) {
+ script_pushint(st, 0); //return 0, according docs
return true;
}
- switch( num ) {
- case 0: script_pushint(st,sd->status.char_id); break;
- case 1: script_pushint(st,sd->status.party_id); break;
- case 2: script_pushint(st,sd->status.guild_id); break;
- case 3: script_pushint(st,sd->status.account_id); break;
- case 4: script_pushint(st,sd->bg_id); break;
- default:
- ShowError("buildin_getcharid: invalid parameter (%d).\n", num);
- script_pushint(st,0);
- break;
+ switch (num) {
+ case 0:
+ script_pushint(st, sd->status.char_id);
+ break;
+ case 1:
+ script_pushint(st, sd->status.party_id);
+ break;
+ case 2:
+ script_pushint(st, sd->status.guild_id);
+ break;
+ case 3:
+ script_pushint(st, sd->status.account_id);
+ break;
+ case 4:
+ script_pushint(st, sd->bg_id);
+ break;
+ case 5:
+ script_pushint(st, sd->status.clan_id);
+ break;
+ default:
+ ShowError("buildin_getcharid: invalid parameter (%d).\n", num);
+ script_pushint(st, 0);
+ break;
}
return true;
@@ -8900,10 +8916,12 @@ BUILDIN(getguildmember)
* 1 : party_name or ""
* 2 : guild_name or ""
* 3 : map_name
+ * 4 : clan_name or ""
* - : ""
*------------------------------------------*/
BUILDIN(strcharinfo)
{
+ struct clan *c;
struct guild* g;
struct party_data* p;
struct map_session_data *sd;
@@ -8943,6 +8961,13 @@ BUILDIN(strcharinfo)
case 3:
script_pushconststr(st, map->list[sd->bl.m].name);
break;
+ case 4:
+ if ((c = sd->clan) != NULL) {
+ script_pushstrcopy(st, c->name);
+ } else {
+ script_pushconststr(st, "");
+ }
+ break;
default:
ShowWarning("script:strcharinfo: unknown parameter.\n");
script_pushconststr(st, "");
@@ -23861,6 +23886,85 @@ BUILDIN(rodex_sendmail2)
}
/**
+ * Clan System: Add a player to a clan
+ */
+BUILDIN(clan_join)
+{
+ struct map_session_data *sd = NULL;
+ int clan_id = script_getnum(st, 2);
+
+ if (script_hasdata(st, 3))
+ sd = map->id2sd(script_getnum(st, 3));
+ else
+ sd = map->id2sd(st->rid);
+
+ if (sd == NULL) {
+ script_pushint(st, false);
+ return false;
+ }
+
+ if (clan->join(sd, clan_id))
+ script_pushint(st, true);
+ else
+ script_pushint(st, false);
+
+ return true;
+}
+
+/**
+ * Clan System: Remove a player from clan
+ */
+BUILDIN(clan_leave)
+{
+ struct map_session_data *sd = NULL;
+
+ if (script_hasdata(st, 2))
+ sd = map->id2sd(script_getnum(st, 2));
+ else
+ sd = map->id2sd(st->rid);
+
+ if (sd == NULL) {
+ script_pushint(st, false);
+ return false;
+ }
+
+ if (clan->leave(sd, false))
+ script_pushint(st, true);
+ else
+ script_pushint(st, false);
+
+ return true;
+}
+
+/**
+ * Clan System: Show clan emblem next to npc name
+ */
+BUILDIN(clan_master)
+{
+ struct npc_data *nd = map->id2nd(st->oid);
+ int clan_id = script_getnum(st, 2);
+
+ if (nd == NULL) {
+ script_pushint(st, false);
+ return false;
+ } else if (clan_id <= 0) {
+ script_pushint(st, false);
+ ShowError("buildin_clan_master: Received Invalid Clan ID %d\n", clan_id);
+ return false;
+ } else if (clan->search(clan_id) == NULL) {
+ script_pushint(st, false);
+ ShowError("buildin_clan_master: Received Id of a nonexistent Clan. Id: %d\n", clan_id);
+ return false;
+ }
+
+ nd->clan_id = clan_id;
+ clif->sc_load(&nd->bl, nd->bl.id, AREA, status->dbs->IconChangeTable[SC_CLAN_INFO], 0, clan_id, 0);
+
+ script_pushint(st, true);
+ return true;
+}
+
+/**
* Adds a built-in script function.
*
* @param buildin Script function data
@@ -24556,6 +24660,11 @@ void script_parse_builtin(void) {
/* Navigation */
BUILDIN_DEF(navigateto, "s??????"),
+ /* Clan System */
+ BUILDIN_DEF(clan_join,"i?"),
+ BUILDIN_DEF(clan_leave,"?"),
+ BUILDIN_DEF(clan_master,"i"),
+
BUILDIN_DEF(channelmes, "ss"),
BUILDIN_DEF(addchannelhandler, "ss"),
BUILDIN_DEF(removechannelhandler, "ss"),
@@ -24923,6 +25032,7 @@ void script_hardcoded_constants(void)
script->set_constant("RENEWAL_ASPD", 0, false, false);
#endif
script->constdb_comment(NULL);
+#include "constants.inc"
}
/**