diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-06-21 21:54:18 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-06-21 21:54:18 +0300 |
commit | 1af2a074bd643a5564a9911ee6cc9356673182be (patch) | |
tree | 4a7ecd8142bf1e2dba841cbb48d4f095d1c86be3 /src/emap | |
parent | 081236e0f54d19058b0fd26abd5c9499df91bbb7 (diff) | |
download | evol-hercules-1af2a074bd643a5564a9911ee6cc9356673182be.tar.gz evol-hercules-1af2a074bd643a5564a9911ee6cc9356673182be.tar.bz2 evol-hercules-1af2a074bd643a5564a9911ee6cc9356673182be.tar.xz evol-hercules-1af2a074bd643a5564a9911ee6cc9356673182be.zip |
Add script command for get card from item by inventory index.
New script command: getcardbyindex itemIndex, cardIndex
Diffstat (limited to 'src/emap')
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 37 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 1 |
3 files changed, 39 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index 03874de..03c8c04 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -148,6 +148,7 @@ HPExport void plugin_init (void) addScriptCommand("successrefindex", "ii", successRefIndex); addScriptCommand("successremovecardsindex", "i", successRemoveCardsIndex); addScriptCommand("failedremovecardsindex", "ii", failedRemoveCardsIndex); + addScriptCommand("getcardbyindex", "ii", getCardByIndex); addScriptCommand("isstr", "v", isStr); addScriptCommand("setbgteam", "ii", setBgTeam); addScriptCommand("checknpccell", "siii", checkNpcCell); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 6a34298..7b5a224 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -1333,6 +1333,43 @@ BUILDIN(failedRemoveCardsIndex) return true; } +BUILDIN(getCardByIndex) +{ + getSD() + getInventoryIndex(2) + + if (sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount <= 0) + { + script_pushint(st, 0); + return false; + } + + const int c = script_getnum(st, 3); + if (c < 0 || c >= MAX_SLOTS) + { + script_pushint(st, 0); + return false; + } + + if (itemdb_isspecial(sd->status.inventory[n].card[0])) + { + script_pushint(st, 0); + return true; + } + + const int card = sd->status.inventory[n].card[c]; + if (card && itemdb_type(card) == IT_CARD) + { + script_pushint(st, card); + } + else + { + script_pushint(st, 0); + } + + return true; +} + // return paramater type // 0 - int // 1 - string diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 6baf5a4..733e0b9 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -49,6 +49,7 @@ BUILDIN(downRefIndex); BUILDIN(successRefIndex); BUILDIN(successRemoveCardsIndex); BUILDIN(failedRemoveCardsIndex); +BUILDIN(getCardByIndex); BUILDIN(isStr); BUILDIN(npcSit); BUILDIN(npcStand); |