Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions db/item_db2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ item_db: (
">
OnEquipScript: <" OnEquip Script (can also be multi-line) ">
OnUnequipScript: <" OnUnequip Script (can also be multi-line) ">
OnRentalStartScript: <" On item renting script, gets called after item is created in inventory (can also be multi-line) ">
OnRentalEndScript: <" On item rent end/expire script, gets called after item is removed from inventory (can also be multi-line) ">
// ================ Optional fields (item_db2 only) ===============
Inherit: true/false (boolean, if true, inherit the values
that weren't specified, from item_db.conf,
Expand Down
57 changes: 48 additions & 9 deletions db/pre-re/item_db.conf
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ item_db: (
">
OnEquipScript: <" OnEquip Script (can also be multi-line) ">
OnUnequipScript: <" OnUnequip Script (can also be multi-line) ">
OnRentalStartScript: <" On item renting script, gets called after item is created in inventory (can also be multi-line) ">
OnRentalEndScript: <" On item rent end/expire script, gets called after item is removed from inventory (can also be multi-line) ">
},
**************************************************************************/

Expand Down Expand Up @@ -69570,7 +69572,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 1; ">
Script: <" setfont(1); ">
OnRentalEndScript: <"
if (getfont() == 1)
setfont(0);
">
},
{
Id: 12288
Expand All @@ -69587,7 +69593,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 2; ">
Script: <" setfont(2); ">
OnRentalEndScript: <"
if (getfont() == 2)
setfont(0);
">
},
{
Id: 12289
Expand All @@ -69604,7 +69614,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 3; ">
Script: <" setfont(3); ">
OnRentalEndScript: <"
if (getfont() == 3)
setfont(0);
">
},
{
Id: 12290
Expand Down Expand Up @@ -69856,7 +69870,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 4; ">
Script: <" setfont(4); ">
OnRentalEndScript: <"
if (getfont() == 4)
setfont(0);
">
},
{
Id: 12305
Expand All @@ -69873,7 +69891,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 5; ">
Script: <" setfont(5); ">
OnRentalEndScript: <"
if (getfont() == 5)
setfont(0);
">
},
{
Id: 12306
Expand All @@ -69890,7 +69912,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 6; ">
Script: <" setfont(6); ">
OnRentalEndScript: <"
if (getfont() == 6)
setfont(0);
">
},
{
Id: 12307
Expand All @@ -69907,7 +69933,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 7; ">
Script: <" setfont(7); ">
OnRentalEndScript: <"
if (getfont() == 7)
setfont(0);
">
},
{
Id: 12308
Expand All @@ -69924,7 +69954,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 8; ">
Script: <" setfont(8); ">
OnRentalEndScript: <"
if (getfont() == 8)
setfont(0);
">
},
{
Id: 12309
Expand All @@ -69941,7 +69975,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 9; ">
Script: <" setfont(9); ">
OnRentalEndScript: <"
if (getfont() == 9)
setfont(0);
">
},
{
Id: 12310
Expand Down Expand Up @@ -73051,6 +73089,7 @@ item_db: (
noauction: true
}
Script: <" setcashmount(); ">
OnRentalEndScript: <" sc_end(SC_ALL_RIDING); ">
},
{
Id: 12701
Expand Down
57 changes: 48 additions & 9 deletions db/re/item_db.conf
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ item_db: (
">
OnEquipScript: <" OnEquip Script (can also be multi-line) ">
OnUnequipScript: <" OnUnequip Script (can also be multi-line) ">
OnRentalStartScript: <" On item renting script, gets called after item is created in inventory (can also be multi-line) ">
OnRentalEndScript: <" On item rent end/expire script, gets called after item is removed from inventory (can also be multi-line) ">
},
**************************************************************************/

Expand Down Expand Up @@ -89226,7 +89228,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 1; ">
Script: <" setfont(1); ">
OnRentalEndScript: <"
if (getfont() == 1)
setfont(0);
">
},
{
Id: 12288
Expand All @@ -89243,7 +89249,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 2; ">
Script: <" setfont(2); ">
OnRentalEndScript: <"
if (getfont() == 2)
setfont(0);
">
},
{
Id: 12289
Expand All @@ -89260,7 +89270,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 3; ">
Script: <" setfont(3); ">
OnRentalEndScript: <"
if (getfont() == 3)
setfont(0);
">
},
{
Id: 12290
Expand Down Expand Up @@ -89512,7 +89526,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 4; ">
Script: <" setfont(4); ">
OnRentalEndScript: <"
if (getfont() == 4)
setfont(0);
">
},
{
Id: 12305
Expand All @@ -89529,7 +89547,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 5; ">
Script: <" setfont(5); ">
OnRentalEndScript: <"
if (getfont() == 5)
setfont(0);
">
},
{
Id: 12306
Expand All @@ -89546,7 +89568,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 6; ">
Script: <" setfont(6); ">
OnRentalEndScript: <"
if (getfont() == 6)
setfont(0);
">
},
{
Id: 12307
Expand All @@ -89563,7 +89589,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 7; ">
Script: <" setfont(7); ">
OnRentalEndScript: <"
if (getfont() == 7)
setfont(0);
">
},
{
Id: 12308
Expand All @@ -89580,7 +89610,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 8; ">
Script: <" setfont(8); ">
OnRentalEndScript: <"
if (getfont() == 8)
setfont(0);
">
},
{
Id: 12309
Expand All @@ -89597,7 +89631,11 @@ item_db: (
nomail: true
noauction: true
}
Script: <" setfont 9; ">
Script: <" setfont(9); ">
OnRentalEndScript: <"
if (getfont() == 9)
setfont(0);
">
},
{
Id: 12310
Expand Down Expand Up @@ -93349,6 +93387,7 @@ item_db: (
noauction: true
}
Script: <" setcashmount(); ">
OnRentalEndScript: <" sc_end(SC_ALL_RIDING); ">
},
{
Id: 12623
Expand Down
6 changes: 6 additions & 0 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9172,6 +9172,12 @@ currently used font is used, default interface font is used again.

---------------------------------------

*getfont()

This command return the player's current font.
if no player is attached it would always return a 0, which is also the default font.

---------------------------------------'
*showdigit(<value>{, <type>})

Displays given numeric 'value' in large digital clock font on top of the
Expand Down
37 changes: 36 additions & 1 deletion src/map/itemdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,14 @@ static int itemdb_validate_entry(struct item_data *entry, int n, const char *sou
script->free_code(entry->unequip_script);
entry->unequip_script = NULL;
}
if (entry->rental_start_script != NULL) {
script->free_code(entry->rental_start_script);
entry->rental_start_script = NULL;
}
if (entry->rental_end_script != NULL) {
script->free_code(entry->rental_end_script);
entry->rental_end_script = NULL;
}
return 0;
#if PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114
}
Expand Down Expand Up @@ -1756,6 +1764,14 @@ static int itemdb_validate_entry(struct item_data *entry, int n, const char *sou
script->free_code(entry->unequip_script);
entry->unequip_script = NULL;
}
if (entry->rental_start_script != NULL) {
script->free_code(entry->rental_start_script);
entry->rental_start_script = NULL;
}
if (entry->rental_end_script != NULL) {
script->free_code(entry->rental_end_script);
entry->rental_end_script = NULL;
}
return 0;
}
}
Expand Down Expand Up @@ -1883,7 +1899,14 @@ static int itemdb_validate_entry(struct item_data *entry, int n, const char *sou
script->free_code(item->unequip_script);
item->unequip_script = NULL;
}

if (item->rental_start_script != NULL && item->rental_start_script != entry->rental_start_script) { // Don't free if it's inheriting the same script
script->free_code(item->rental_start_script);
item->rental_start_script = NULL;
}
if (item->rental_end_script != NULL && item->rental_end_script != entry->rental_end_script) { // Don't free if it's inheriting the same script
script->free_code(item->rental_end_script);
item->rental_end_script = NULL;
}
*item = *entry;
return item->nameid;
}
Expand Down Expand Up @@ -1999,6 +2022,8 @@ static int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const
* ">
* OnEquipScript: <" OnEquip Script ">
* OnUnequipScript: <" OnUnequip Script ">
* OnRentalStartScript: <" on renting script ">
* OnRentalEndScript: <" on renting end script ">
* Inherit: inherit or override
*/
if( !itemdb->lookup_const(it, "Id", &i32) ) {
Expand Down Expand Up @@ -2276,6 +2301,12 @@ static int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const
if( libconfig->setting_lookup_string(it, "OnUnequipScript", &str) )
id.unequip_script = *str ? script->parse(str, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL;

if (libconfig->setting_lookup_string(it, "OnRentalStartScript", &str) != CONFIG_FALSE)
id.rental_start_script = (*str != '\0') ? script->parse(str, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL;

if (libconfig->setting_lookup_string(it, "OnRentalEndScript", &str) != CONFIG_FALSE)
id.rental_end_script = (*str != '\0') ? script->parse(str, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL;

return itemdb->validate_entry(&id, n, source);
}

Expand Down Expand Up @@ -2519,6 +2550,10 @@ static void destroy_item_data(struct item_data *self, int free_self)
script->free_code(self->equip_script);
if( self->unequip_script )
script->free_code(self->unequip_script);
if (self->rental_start_script != NULL)
script->free_code(self->rental_start_script);
if (self->rental_end_script != NULL)
script->free_code(self->rental_end_script);
if( self->combos )
aFree(self->combos);
HPM->data_store_destroy(&self->hdata);
Expand Down
2 changes: 2 additions & 0 deletions src/map/itemdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ struct item_data {
struct script_code *script; ///< Default script for everything.
struct script_code *equip_script; ///< Script executed once when equipping.
struct script_code *unequip_script; ///< Script executed once when unequipping.
struct script_code *rental_start_script; ///< Script executed once this item get rented
struct script_code *rental_end_script; ///< Script executed once this item rent ends
struct {
unsigned available : 1;
unsigned no_refine : 1; // [celest]
Expand Down
Loading