diff options
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 83 |
1 files changed, 83 insertions, 0 deletions
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; +} |