summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-24 17:48:55 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-24 17:48:55 +0300
commitce563a50ff4997f4a3f1ccd8bd1fdec5708b3bff (patch)
tree163c40267ec7ad9edf32ec6a3e06a12f6b1132b0 /src
parente7cd9086185804d815fb0dc72e3bfd36fdd9a33f (diff)
downloadevol-hercules-ce563a50ff4997f4a3f1ccd8bd1fdec5708b3bff.tar.gz
evol-hercules-ce563a50ff4997f4a3f1ccd8bd1fdec5708b3bff.tar.bz2
evol-hercules-ce563a50ff4997f4a3f1ccd8bd1fdec5708b3bff.tar.xz
evol-hercules-ce563a50ff4997f4a3f1ccd8bd1fdec5708b3bff.zip
Add script function for get return code from craft entry.
New script function: getcraftcode ENTRY
Diffstat (limited to 'src')
-rw-r--r--src/emap/craft.c12
-rw-r--r--src/emap/craft.h2
-rw-r--r--src/emap/craftconf.c2
-rw-r--r--src/emap/craftconf.h1
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script.c9
-rw-r--r--src/emap/script.h1
7 files changed, 27 insertions, 1 deletions
diff --git a/src/emap/craft.c b/src/emap/craft.c
index 2ea33bc..7081911 100644
--- a/src/emap/craft.c
+++ b/src/emap/craft.c
@@ -834,3 +834,15 @@ bool craft_use(TBL_PC *sd,
clif->updatestatus(sd, SP_WEIGHT);
return true;
}
+
+int craft_get_entry_code(TBL_PC *sd,
+ const int id)
+{
+ struct craft_db_entry *entry = idb_get(craftconf_db, id);
+ if (!entry)
+ {
+ ShowError("Craft config entry with id %d not exists.\n", id);
+ return -1;
+ }
+ return entry->return_code;
+}
diff --git a/src/emap/craft.h b/src/emap/craft.h
index 2763907..329dbb4 100644
--- a/src/emap/craft.h
+++ b/src/emap/craft.h
@@ -42,5 +42,7 @@ struct craft_slot *craft_get_slot(const int id, const int slot);
bool craft_validate(TBL_PC *sd, const int id);
int craft_find_entry(TBL_PC *sd, const int craftvar, const int flag);
bool craft_use_entry(TBL_PC *sd, const int id);
+bool craft_use(TBL_PC *sd, const int id);
+int craft_get_entry_code(TBL_PC *sd, const int id);
#endif // EVOL_MAP_CRAFT
diff --git a/src/emap/craftconf.c b/src/emap/craftconf.c
index 7afba56..cab5168 100644
--- a/src/emap/craftconf.c
+++ b/src/emap/craftconf.c
@@ -39,6 +39,7 @@ struct craft_db_entry *craft_create_db_entry(const int id)
VECTOR_INIT(entry->required_skills);
VECTOR_INIT(entry->required_quests);
entry->selected_inventory = NULL;
+// entry->return_code = 0;
return entry;
}
@@ -284,6 +285,7 @@ static bool craft_read_db_sub(config_setting_t *craftt, int id, const char *sour
readField("Price", price, 0);
readField("Lv", level, 0);
readField("Flag", flag, -1);
+ readField("ReturnCode", return_code, 0);
if ((t = libconfig->setting_get_member(craftt, "SourceItems")) && config_setting_is_list(t))
{
diff --git a/src/emap/craftconf.h b/src/emap/craftconf.h
index 235b984..c243218 100644
--- a/src/emap/craftconf.h
+++ b/src/emap/craftconf.h
@@ -35,6 +35,7 @@ struct craft_db_entry
int price;
int level;
int flag;
+ int return_code;
};
enum craft_field_type
diff --git a/src/emap/init.c b/src/emap/init.c
index bb732ed..0e1463a 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -107,6 +107,7 @@ HPExport void plugin_init (void)
addScriptCommand("deletecraft", "i", deleteCraft);
addScriptCommand("findcraftentry", "ii", findCraftEntry);
addScriptCommand("usecraft", "i", useCraft);
+ addScriptCommand("getcraftcode", "i", getCraftCode);
addScriptCommand("getcraftslotid", "ii", getCraftSlotId);
addScriptCommand("getcraftslotamount", "ii", getCraftSlotAmount);
addScriptCommand("validatecraft", "i", validateCraft);
diff --git a/src/emap/script.c b/src/emap/script.c
index 69c1f4e..bc8c7b2 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -1954,10 +1954,17 @@ BUILDIN(findCraftEntry)
BUILDIN(useCraft)
{
- getSDReturn(0)
+ getSD()
return craft_use(sd, script_getnum(st, 2));
}
+BUILDIN(getCraftCode)
+{
+ getSDReturn(-1)
+ script_pushint(st, craft_get_entry_code(sd, script_getnum(st, 2)));
+ return true;
+}
+
BUILDIN(getInvIndexLink)
{
getSDReturnS("")
diff --git a/src/emap/script.h b/src/emap/script.h
index 67c20e6..d91cf9d 100644
--- a/src/emap/script.h
+++ b/src/emap/script.h
@@ -75,5 +75,6 @@ BUILDIN(getInvIndexLink);
BUILDIN(emotion);
BUILDIN(findCraftEntry);
BUILDIN(useCraft);
+BUILDIN(getCraftCode);
#endif // EVOL_MAP_SCRIPT