summaryrefslogtreecommitdiff
path: root/src/emap
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-19 18:55:20 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-19 18:56:34 +0300
commit73defa73651a5e6f7683dc90ab465d19496b8cca (patch)
tree2b7e5ba8e7369e31812c5529aefcca8d5dfe333c /src/emap
parent6eb6d10d8e1f4fa01d6a5bdc222149cd8552eb6a (diff)
downloadplugin-73defa73651a5e6f7683dc90ab465d19496b8cca.tar.gz
plugin-73defa73651a5e6f7683dc90ab465d19496b8cca.tar.bz2
plugin-73defa73651a5e6f7683dc90ab465d19496b8cca.tar.xz
plugin-73defa73651a5e6f7683dc90ab465d19496b8cca.zip
Add extended mount support.
Diffstat (limited to 'src/emap')
-rw-r--r--src/emap/init.c4
-rw-r--r--src/emap/pc.c7
-rw-r--r--src/emap/script.c94
-rw-r--r--src/emap/send.h6
4 files changed, 22 insertions, 89 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index cfa8940..4d55b42 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -119,7 +119,6 @@ HPExport void plugin_init (void)
addScriptCommand("ispcdead", "", isPcDead);
addScriptCommand("areatimer", "siiiii*", areaTimer);
addScriptCommand("getareadropitem", "siiiiv*", getAreaDropItem);
- addScriptCommand("setmount", "?", setMount);
addScriptCommand("clientcommand", "s", clientCommand);
addScriptCommand("isunitwalking", "?", isUnitWalking);
addScriptCommand("failedrefindex", "i", failedRefIndex);
@@ -130,6 +129,7 @@ HPExport void plugin_init (void)
addScriptCommand("checknpccell", "siii", checkNpcCell);
addScriptCommand("setcells", "siiiiis", setCells);
addScriptCommand("delcells", "s", delCells);
+ addScriptCommand("setmount", "i", setMount);
do_init_langs();
@@ -229,7 +229,7 @@ HPExport void plugin_init (void)
addHookPost("pc->insert_card", epc_insert_card_post);
langScriptId = script->add_str("Lang");
- mountScriptId = script->add_str("Mount");
+ mountScriptId = script->add_str("mount");
}
HPExport void server_preinit (void)
diff --git a/src/emap/pc.c b/src/emap/pc.c
index a099c3c..152fabe 100644
--- a/src/emap/pc.c
+++ b/src/emap/pc.c
@@ -19,6 +19,7 @@
#include "emap/clif.h"
#include "emap/pc.h"
+#include "emap/send.h"
#include "emap/script.h"
#include "emap/data/itemd.h"
#include "emap/data/mapd.h"
@@ -57,7 +58,11 @@ int epc_setregistry(TBL_PC *sd, int64 *reg, int *val)
struct SessionExt *data = session_get_bysd(sd);
if (!data)
return 0;
- data->mount = *val;
+ if (data->mount != *val)
+ {
+ data->mount = *val;
+ send_pc_info(&sd->bl, &sd->bl, SELF);
+ }
}
return 0;
diff --git a/src/emap/script.c b/src/emap/script.c
index f09098e..3c41723 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -85,6 +85,8 @@
if (!nd) \
return r;
+extern int mountScriptId;
+
void eset_reg_npcscope_num(struct script_state* st, struct reg_db *n, int64 *num, const char* name, int *val)
{
if (!strcmp(name, ".lang"))
@@ -1423,89 +1425,6 @@ BUILDIN(getAreaDropItem)
return true;
}
-enum setmount_type
-{
- SETMOUNT_TYPE_NONE = 0,
- SETMOUNT_TYPE_PECO = 1,
- SETMOUNT_TYPE_WUG = 2,
- SETMOUNT_TYPE_MADO = 3,
- SETMOUNT_TYPE_DRAGON_GREEN = 4,
- SETMOUNT_TYPE_DRAGON_BROWN = 5,
- SETMOUNT_TYPE_DRAGON_GRAY = 6,
- SETMOUNT_TYPE_DRAGON_BLUE = 7,
- SETMOUNT_TYPE_DRAGON_RED = 8,
- SETMOUNT_TYPE_MAX,
- SETMOUNT_TYPE_DRAGON = SETMOUNT_TYPE_DRAGON_GREEN,
-};
-
-BUILDIN(setMount)
-{
- int flag = SETMOUNT_TYPE_NONE;
- TBL_PC* sd = script->rid2sd(st);
-
- if (sd == NULL)
- return true; // no player attached, report source
-
- if (script_hasdata(st, 2))
- flag = script_getnum(st, 2);
-
- // Sanity checks and auto-detection
- if (flag >= SETMOUNT_TYPE_DRAGON_GREEN && flag <= SETMOUNT_TYPE_DRAGON_RED)
- {
- if (pc->checkskill(sd, RK_DRAGONTRAINING))
- {
- // Rune Knight (Dragon)
- unsigned int option;
- option = ( flag == SETMOUNT_TYPE_DRAGON_GREEN ? OPTION_DRAGON1 :
- flag == SETMOUNT_TYPE_DRAGON_BROWN ? OPTION_DRAGON2 :
- flag == SETMOUNT_TYPE_DRAGON_GRAY ? OPTION_DRAGON3 :
- flag == SETMOUNT_TYPE_DRAGON_BLUE ? OPTION_DRAGON4 :
- flag == SETMOUNT_TYPE_DRAGON_RED ? OPTION_DRAGON5 :
- OPTION_DRAGON1); // default value
- pc->setridingdragon(sd, option);
- }
- }
- else if (flag == SETMOUNT_TYPE_WUG)
- {
- // Ranger (Warg)
- if (pc->checkskill(sd, RA_WUGRIDER))
- pc->setridingwug(sd, true);
- }
- else if (flag == SETMOUNT_TYPE_MADO)
- {
- // Mechanic (Mado Gear)
- if (pc->checkskill(sd, NC_MADOLICENCE))
- pc->setmadogear(sd, true);
- }
- else if (flag == SETMOUNT_TYPE_PECO)
- {
- // Knight / Crusader (Peco Peco)
- if (pc->checkskill(sd, KN_RIDING))
- pc->setridingpeco(sd, true);
- }
- else if (flag == SETMOUNT_TYPE_NONE && pc_hasmount(sd))
- {
- if (pc_isridingdragon(sd))
- {
- pc->setridingdragon(sd, 0);
- }
- if (pc_isridingwug(sd))
- {
- pc->setridingwug(sd, false);
- }
- if (pc_ismadogear(sd))
- {
- pc->setmadogear(sd, false);
- }
- if (pc_isridingpeco(sd))
- {
- pc->setridingpeco(sd, false);
- }
- }
-
- return true;
-}
-
BUILDIN(clientCommand)
{
getSD();
@@ -1848,3 +1767,12 @@ BUILDIN(delCells)
map->iwall_remove(name);
return true;
}
+
+BUILDIN(setMount)
+{
+ getSD()
+ int mount = script_getnum(st, 2);
+ pc_setglobalreg(sd, mountScriptId, mount);
+ send_pc_info(&sd->bl, &sd->bl, AREA);
+ return true;
+}
diff --git a/src/emap/send.h b/src/emap/send.h
index b11b0a7..aec7e60 100644
--- a/src/emap/send.h
+++ b/src/emap/send.h
@@ -1,8 +1,8 @@
// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// Copyright (c) 2014 - 2015 Evol developers
-#ifndef EVOL_MAP_PC
-#define EVOL_MAP_PC
+#ifndef EVOL_MAP_SEND
+#define EVOL_MAP_SEND
void send_npccommand (TBL_PC *sd, int npcId, int cmd);
void send_npccommand2 (TBL_PC *sd, int npcId, int cmd, int id, int x, int y);
@@ -44,4 +44,4 @@ void send_setwall_single(int fd,
int x2, int y2,
int mask);
-#endif // EVOL_MAP_PC
+#endif // EVOL_MAP_SEND