From ec8aa5c770bcaaaa6f5066e68a2113a8b583066f Mon Sep 17 00:00:00 2001 From: Taylor Locke Date: Wed, 22 Oct 2014 03:07:37 +0200 Subject: Re-commit of 4ac673941714032ada6d26fb60936ec510bbe496 (part 3) Some Quality of Life Changes - setdragon, setmadogear and setriding deprecated; use setmount instead. - checkdragon, checkmadogear, checkriding deprecated; use checkmount instead. Signed-off-by: Haru --- db/const.txt | 12 +++++ doc/script_commands.txt | 55 ++++++++++++++++++++ src/map/script.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) diff --git a/db/const.txt b/db/const.txt index a53866b7c..8f649b4f3 100644 --- a/db/const.txt +++ b/db/const.txt @@ -3362,3 +3362,15 @@ SCFLAG_FIXEDTICK 0x02 SCFLAG_LOADED 0x04 SCFLAG_FIXEDRATE 0x08 SCFLAG_NOICON 0x10 + +// Mount types +MOUNT_NONE 0 +MOUNT_PECO 1 +MOUNT_WUG 2 +MOUNT_MADO 3 +MOUNT_DRAGON 4 +MOUNT_DRAGON_GREEN 4 +MOUNT_DRAGON_BROWN 5 +MOUNT_DRAGON_GRAY 6 +MOUNT_DRAGON_BLUE 7 +MOUNT_DRAGON_RED 8 diff --git a/doc/script_commands.txt b/doc/script_commands.txt index c72910d12..651ce05e2 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3819,9 +3819,60 @@ falcon and 0 if they don't. --------------------------------------- +*setmount {}; +*checkmount() + +If is MOUNT_NONE (or 0) this command will remove the mount from the +character. + +Otherwise it gives the invoking character the desired combat mount, where +allowed by their class and skills. + +If no flag is specified, the mount is automatically chosen according to the +character's class and skills. + +The following flag values are accepted: + + MOUNT_NONE: + - Dismount + MOUNT_PECO: + - PecoPeco (Knight series class) + - GrandPeco (Crusader series class) + - Gryphon (Royal Guard) + MOUNT_WUG: + - Warg (Ranger) + MOUNT_MADO: + - Mado Gear (Mechanic) + MOUNT_DRAGON: + MOUNT_DRAGON_GREEN: + MOUNT_DRAGON_BROWN: + MOUNT_DRAGON_GRAY: + MOUNT_DRAGON_BLUE: + MOUNT_DRAGON_RED: + - Dragon (Rune Knight) + if MOUNT_DRAGON is specified, a the default (green) dragon will be used. + +Unlike 'setfalcon' and 'setcart' this will not work at all if they aren't of a +class which can ride a mount. + +The accompanying function will return 0 if the invoking character is not on a +mount, and a non-zero value (according to the above constants) if they are. +Note: in case of dragons, the returned value will always be MOUNT_DRAGON, +regardless of color. + + if (checkmount()) + mes "Leave your mount outside! No riding mounts on the floor here!"; + + if (checkmount() == MOUNT_DRAGON) + mes "Wow, your dragon is cool! Can I pet it?"; + +--------------------------------------- + *setriding {}; *checkriding() +[ DEPRECATED - Please use setmount / checkmount] + If is 0 this command will remove the mount from the character. Otherwise it gives the invoking character a PecoPeco (if they are a Knight series class), a GrandPeco (if they are a Crusader series class), or @@ -3839,6 +3890,8 @@ riding a bird and 0 if they aren't. *setdragon {}; *checkdragon() +[ DEPRECATED - Please use setmount / checkmount] + The 'setdragon' function toggles mounting a dragon for the invoking character. It will return 1 if successful, 0 otherwise. @@ -3860,6 +3913,8 @@ riding a dragon and 0 if they aren't. *setmadogear {}; *checkmadogear() +[ DEPRECATED - Please use setmount / checkmount] + If is 0 this command will remove the mount from the character. Otherwise it gives the invoking character a Mado (if they are a Mechanic). diff --git a/src/map/script.c b/src/map/script.c index f71b0e64b..f6c8e8651 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8711,6 +8711,137 @@ BUILDIN(setriding) return true; } +enum setmount_type { + SETMOUNT_TYPE_AUTODETECT = -1, + 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, +}; + +/** + * Checks if the player is riding a combat mount. + * + * Returns 0 if the player isn't riding, and non-zero if it is. + * The exact returned values are the same used as flag in setmount, except for + * dragons, where SETMOUNT_TYPE_DRAGON is returned, regardless of color. + */ +BUILDIN(checkmount) +{ + TBL_PC* sd; + + sd = script->rid2sd(st); + if (sd == NULL) + return true; // no player attached, report source + + if (!pc_hasmount(sd)) { + script_pushint(st, SETMOUNT_TYPE_NONE); + } else if (pc_isridingpeco(sd)) { + script_pushint(st, SETMOUNT_TYPE_PECO); + } else if (pc_isridingwug(sd)) { + script_pushint(st, SETMOUNT_TYPE_WUG); + } else if (pc_ismadogear(sd)) { + script_pushint(st, SETMOUNT_TYPE_MADO); + } else { // if (pc_isridingdragon(sd)) + script_pushint(st, SETMOUNT_TYPE_DRAGON); + } + + return true; +} + +/** + * Mounts or dismounts a combat mount. + * + * setmount ; + * setmount; + * + * Accepted values for flag: + * MOUNT_NONE - dismount + * MOUNT_PECO - Peco Peco / Grand Peco / Gryphon (depending on the class) + * MOUNT_WUG - Wug (Rider) + * MOUNT_MADO - Mado Gear + * MOUNT_DRAGON - Dragon (default color) + * MOUNT_DRAGON_GREEN - Green Dragon + * MOUNT_DRAGON_BROWN - Brown Dragon + * MOUNT_DRAGON_GRAY - Gray Dragon + * MOUNT_DRAGON_BLUE - Blue Dragon + * MOUNT_DRAGON_RED - Red Dragon + * + * If an invalid value or no flag is specified, the appropriate mount is + * auto-detected. As a result of this, there is no need to specify a flag at + * all, unless it is a dragon color other than green. + */ +BUILDIN(setmount) +{ + int flag = SETMOUNT_TYPE_AUTODETECT; + TBL_PC* sd; + + sd = script->rid2sd(st); + + if (sd == NULL) + return true;// no player attached, report source + + if (script_hasdata(st,2)) + flag = script_getnum(st,2); + + // Color variants for Rune Knight dragon mounts. + if (flag != SETMOUNT_TYPE_NONE) { + if (flag < SETMOUNT_TYPE_AUTODETECT || flag >= SETMOUNT_TYPE_MAX) { + ShowWarning("script_setmount: Unknown flag %d specified. Using auto-detected value.\n", flag); + flag = SETMOUNT_TYPE_AUTODETECT; + } + // Sanity checks and auto-detection + if ((sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) { + 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_RED ? OPTION_DRAGON4 : + flag == SETMOUNT_TYPE_DRAGON_RED ? OPTION_DRAGON5 : + OPTION_DRAGON1); // default value + pc->setridingdragon(sd, option); + } else if ((sd->class_&MAPID_THIRDMASK) == MAPID_RANGER) { + // Ranger (Warg) + if (pc->checkskill(sd, RA_WUGRIDER)) + pc->setridingwug(sd, true); + } else if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) { + // Mechanic (Mado Gear) + if (pc->checkskill(sd, NC_MADOLICENCE)) + pc->setmadogear(sd, true); + } else if (flag != SETMOUNT_TYPE_PECO) + flag = SETMOUNT_TYPE_PECO; + } else { + // Knight / Crusader (Peco Peco) + if (pc->checkskill(sd, KN_RIDING)) + pc->setridingpeco(sd, true); + } + } else if (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; +} + /// Returns if the player has a warg. /// /// checkwug() -> @@ -18981,6 +19112,8 @@ void script_parse_builtin(void) { BUILDIN_DEF(checkfalcon,""), BUILDIN_DEF(setriding,"?"), BUILDIN_DEF(checkriding,""), + BUILDIN_DEF(setmount,"?"), + BUILDIN_DEF(checkmount,""), BUILDIN_DEF(checkwug,""), BUILDIN_DEF(checkmadogear,""), BUILDIN_DEF(setmadogear,"?"), -- cgit v1.2.3-60-g2f50