diff options
-rw-r--r-- | src/map/init.c | 1 | ||||
-rw-r--r-- | src/map/script.c | 83 | ||||
-rw-r--r-- | src/map/script.h | 1 |
3 files changed, 85 insertions, 0 deletions
diff --git a/src/map/init.c b/src/map/init.c index 170839a..7635e67 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -102,6 +102,7 @@ HPExport void plugin_init (void) addScriptCommand("ispcdead", "", isPcDead); addScriptCommand("areatimer", "siiiii*", areaTimer); addScriptCommand("getareadropitem", "siiiiv*", getAreaDropItem); + addScriptCommand("setmount", "?", setMount); do_init_langs(); diff --git a/src/map/script.c b/src/map/script.c index c582fd5..efd117a 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1014,3 +1014,86 @@ BUILDIN(getAreaDropItem) script_pushint(st, amount); 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; +} diff --git a/src/map/script.h b/src/map/script.h index b31cfb1..b9247b3 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -39,5 +39,6 @@ BUILDIN(unequipById); BUILDIN(isPcDead); BUILDIN(areaTimer); BUILDIN(getAreaDropItem); +BUILDIN(setMount); #endif // EVOL_MAP_SCRIPT |