Added refine and bound options for mail command (#4272)

* Added refine and bound option for mail script command.
* Made some slight corrections to the script_commands document.
* Note: Any custom scripts that use this command and give some sort of card or random option bonus need to be adjusted as refine and bound come before these options now.
Thanks to @Skormie!
Co-authored-by: Daegaladh <Daegaladh@users.noreply.github.com>
This commit is contained in:
Jason L 2020-02-11 10:18:59 -05:00 committed by GitHub
parent 986f8b0595
commit e5c22b360f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 13 deletions

View File

@ -2248,7 +2248,7 @@ Notice that .@array[4] and .@array[5] won't be copied to the second array, and i
---------------------------------------
*deletearray <array name>[<first value>],<how much to delete>;
*deletearray <array name>[<first value>]{,<how much to delete>};
This command will delete a specified number of array elements totally from an
array, shifting all the elements beyond this towards the beginning.
@ -5436,10 +5436,10 @@ invoking character.
---------------------------------------
*mail <destination id>,"<sender name>","<title>","<body>"{,<zeny>{,<item id array>,<item amount array>{,<item card0 array>{,<item card1 array>{,<item card2 array>{,<item card3 array>
*mail <destination id>,"<sender name>","<title>","<body>"{,<zeny>{,<item id array>,<item amount array>{,refine{,bound{,<item card0 array>{,<item card1 array>{,<item card2 array>{,<item card3 array>
{,<random option id0 array>, <random option value0 array>, <random option paramter0 array>{,<random option id1 array>, <random option value1 array>, <random option paramter1 array>
{,<random option id2 array>, <random option value2 array>, <random option paramter2 array>{,<random option id3 array>, <random option value3 array>, <random option paramter3 array>
{,<random option id4 array>, <random option value4 array>, <random option paramter4 array>}}}}}}};
{,<random option id4 array>, <random option value4 array>, <random option paramter4 array>}}}}}}}}};
This command will send mail to the <destination id> which is a character ID.
A <sender name> can be specified but does not have to be from the direct creator
@ -5472,10 +5472,12 @@ Example of sending mail with items:
.@zeny = 0;
setarray .@mailitem[0], 504, 505, 2220, 1214; // White Potion, Blue Potion, Hat, Dagger
setarray .@mailamount[0], 10, 5, 1, 1; // 10 White Potions, 5 Blue Potions, 1 Hat, 1 Dagger
setarray .@mailrefine[0], 0, 0, 3, 10; // +3 Hat, +10 Dagger
setarray .@mailbound[0], 0, 0, Bound_Account, Bound_Char; // Account bounded Hat, Char bounded Dagger
setarray .@mailcard0[0], 0, 0, 4198, 4092; // Attach Maya Purple Card to the Hat, Attach Skeleton Worker Card to Dagger
setarray .@mailcard1[0], 0, 0, 0, 4092; // Attach Skeleton Worker Card to Dagger
setarray .@mailcard2[0], 0, 0, 0, 4092; // Attach Skeleton Worker Card to Dagger
mail .@charid, .@sender$, .@title$, .@body$, .@zeny, .@mailitem, .@mailamount, .@mailcard0, .@mailcard1, .@mailcard2;
mail .@charid, .@sender$, .@title$, .@body$, .@zeny, .@mailitem, .@mailamount, .@mailrefine, .@mailbound, .@mailcard0, .@mailcard1, .@mailcard2;
Example of sending mail with items and random options:
.@charid = getcharid(0);
@ -5485,14 +5487,16 @@ Example of sending mail with items and random options:
.@zeny = 0;
setarray .@mailitem[0], 504, 505, 2220, 1214; // White Potion, Blue Potion, Hat, Dagger
setarray .@mailamount[0], 10, 5, 1, 1; // 10 White Potions, 5 Blue Potions, 1 Hat, 1 Dagger
setarray .@mailrefine[0], 0, 0, 3, 10; // +3 Hat, +10 Dagger
setarray .@mailbound[0], 0, 0, Bound_Account, Bound_Char; // Account bounded Hat, Char bounded Dagger
setarray .@mailcard0[0], 0, 0, 4198, 4092; // Attach Maya Purple Card to the Hat, Attach Skeleton Worker Card to Dagger
setarray .@mailcard1[0], 0, 0, 0, 4092; // Attach Skeleton Worker Card to Dagger
setarray .@mailcard2[0], 0, 0, 0, 4092; // Attach Skeleton Worker Card to Dagger
setarray .@mailcard3[0], 0, 0, 0, 0; // Empty last slot
setarray .@mailrndopt_id0[0], 0, 0, 0, 0, RDMOPT_VAR_MAXHPAMOUNT; // Enchant the Dagger with increased HP option
setarray .@mailrndopt_val0[0], 0, 0, 0, 0, 1000; // Enchant the Dagger with increased HP option by 1000 points
setarray .@mailrndopt_prm0[0], 0, 0, 0, 0, 0; // Enchant the Dagger with increased HP option - does not need any parameter
mail .@charid, .@sender$, .@title$, .@body$, .@zeny, .@mailitem, .@mailamount, .@mailcard0, .@mailcard1, .@mailcard2, .@mailcard3, .@mailrndopt_id0, .@mailrndopt_val0, .@mailrndopt_prm0;
setarray .@mailrndopt_id0[0], 0, 0, 0, RDMOPT_VAR_MAXHPAMOUNT; // Enchant the Dagger with increased HP option
setarray .@mailrndopt_val0[0], 0, 0, 0, 1000; // Enchant the Dagger with increased HP option by 1000 points
setarray .@mailrndopt_prm0[0], 0, 0, 0, 0; // Enchant the Dagger with increased HP option - does not need any parameter
mail .@charid, .@sender$, .@title$, .@body$, .@zeny, .@mailitem, .@mailamount, .@mailrefine, .@mailbound, .@mailcard0, .@mailcard1, .@mailcard2, .@mailcard3, .@mailrndopt_id0, .@mailrndopt_val0, .@mailrndopt_prm0;
---------------------------------------

View File

@ -24046,6 +24046,7 @@ static inline bool mail_sub( struct script_state *st, struct script_data *data,
return true;
}
// mail <destination id>,"<sender name>","<title>","<body>"{,<zeny>{,<item id array>,<item amount array>{,refine{,bound{,<item card0 array>{,<item card1 array>{,<item card2 array>{,<item card3 array>{,<random option id0 array>, <random option value0 array>, <random option paramter0 array>{,<random option id1 array>, <random option value1 array>, <random option paramter1 array>{,<random option id2 array>, <random option value2 array>, <random option paramter2 array>{,<random option id3 array>, <random option value3 array>, <random option paramter3 array>{,<random option id4 array>, <random option value4 array>, <random option paramter4 array>}}}}}}}}};
BUILDIN_FUNC(mail){
const char *sender, *title, *body, *name;
struct mail_message msg;
@ -24165,12 +24166,66 @@ BUILDIN_FUNC(mail){
}
}
// Cards
if( !script_hasdata(st,9) ){
// Refine
if (!script_hasdata(st, 9)) {
ShowError("buildin_mail: missing item refine variable at position %d.\n", 9);
break;
}
for( i = 0, j = 9; i < MAX_SLOTS && script_hasdata(st,j); i++, j++ ){
data = script_getdata(st, 9);
if (!mail_sub(st, data, sd, 9, &name, &start, &end, &id)) {
return SCRIPT_CMD_FAILURE;
}
for (i = 0; i < num_items && start < end; i++, start++) {
struct item_data* item = itemdb_exists(msg.item[i].nameid);
msg.item[i].refine = (char)get_val2_num( st, reference_uid( id, start ), reference_getref( data ) );
script_removetop(st, -1, 0);
if (!item->flag.no_refine && (item->type == IT_WEAPON || item->type == IT_ARMOR || item->type == IT_SHADOWGEAR)) {
if (msg.item[i].refine > MAX_REFINE)
msg.item[i].refine = MAX_REFINE;
}
else
msg.item[i].refine = 0;
if (msg.item[i].refine < 0)
msg.item[i].refine = 0;
}
// Bound
if (!script_hasdata(st, 10)) {
ShowError("buildin_mail: missing item bound variable at position %d.\n", 10);
break;
}
data = script_getdata(st,10);
if( !mail_sub( st, data, sd, 10, &name, &start, &end, &id ) ){
return SCRIPT_CMD_FAILURE;
}
for( i = 0; i < num_items && start < end; i++, start++ ){
struct item_data *item = itemdb_exists(msg.item[i].nameid);
msg.item[i].bound = (char)get_val2_num( st, reference_uid( id, start ), reference_getref( data ) );
script_removetop(st, -1, 0);
if( msg.item[i].bound <= BOUND_NONE || msg.item[i].bound >= BOUND_MAX ){
ShowError( "buildin_mail: bound %d for item %hu is invalid.\n", msg.item[i].bound, msg.item[i].nameid );
return SCRIPT_CMD_FAILURE;
}
}
// Cards
if( !script_hasdata(st,11) ){
break;
}
for( i = 0, j = 11; i < MAX_SLOTS && script_hasdata(st,j); i++, j++ ){
data = script_getdata(st,j);
if( !mail_sub( st, data, sd, j + 1, &name, &start, &end, &id ) ){
@ -24188,11 +24243,11 @@ BUILDIN_FUNC(mail){
}
// Random Options
if( !script_hasdata(st,9 + MAX_SLOTS) ){
if( !script_hasdata(st,12 + MAX_SLOTS) ){
break;
}
for( i = 0, j = 9 + MAX_SLOTS; i < MAX_ITEM_RDM_OPT && script_hasdata(st,j) && script_hasdata(st,j + 1) && script_hasdata(st,j + 2); i++, j++ ){
for( i = 0, j = 12 + MAX_SLOTS; i < MAX_ITEM_RDM_OPT && script_hasdata(st,j) && script_hasdata(st,j + 1) && script_hasdata(st,j + 2); i++, j++ ){
// Option IDs
data = script_getdata(st, j);