Implemented basic script commands to apply options to equipped item.
This commit is contained in:
parent
da21013254
commit
8deabb157a
@ -9172,5 +9172,45 @@ Requires client 2015-05-13aRagEXE or newer.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*getrandomoptinfo(<type>);
|
||||
|
||||
Returns value of an attribute of current random option.
|
||||
|
||||
Valid attributes are:
|
||||
ROA_ID - ID of current option
|
||||
ROA_VALUE - Value field of current option
|
||||
ROA_PARAM - Param field of current option
|
||||
|
||||
This script command is intended for using in random option scripts.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*getequiprandomoption(<equipment indice>,<index>,<type>{,<char id>});
|
||||
|
||||
Returns value of an attribute of a random option on an equipped item.
|
||||
|
||||
For valid equipment indices, see `getequipid` command reference.
|
||||
|
||||
index parameter can be 0 to MAX_ITEM_RDM_OPT-1 (default 0-4).
|
||||
|
||||
For valid attribute types, see `getrandomoptinfo` command reference.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*setrandomoption(<equipment indice>,<index>,<id>,<value>,<param>{,<char id>});
|
||||
|
||||
Sets <index+1>th random option for equipment equipped at <equipment indice>
|
||||
to <id>, <value> and <param>.
|
||||
|
||||
For valid equipment indices, see `getequipid` command reference.
|
||||
|
||||
index parameter can be 0 to MAX_ITEM_RDM_OPT-1 (default 0-4).
|
||||
|
||||
ID - ID of random option. See db/const.txt for constants.
|
||||
Value - Value of random option
|
||||
Param - Parameter of random option
|
||||
|
||||
---------------------------------------
|
||||
|
||||
Whew.
|
||||
That's about all of them.
|
||||
|
@ -535,7 +535,7 @@ uint16 itemdb_get_randgroupitem_count(uint16 group_id, uint8 sub_group, unsigned
|
||||
|
||||
bool itemdb_parse_roulette_db(void);
|
||||
|
||||
struct s_random_opt_data* itemdb_randomopt_exists(short id);
|
||||
struct s_random_opt_data *itemdb_randomopt_exists(short id);
|
||||
|
||||
void itemdb_reload(void);
|
||||
|
||||
|
125
src/map/script.c
125
src/map/script.c
@ -21536,16 +21536,25 @@ BUILDIN_FUNC(hateffect){
|
||||
**/
|
||||
BUILDIN_FUNC(getrandomoptinfo) {
|
||||
struct map_session_data *sd;
|
||||
int param = script_getnum(st, 1);
|
||||
int val;
|
||||
int param = script_getnum(st, 2);
|
||||
if ((sd = script_rid2sd(st)) != NULL && current_equip_item_index && current_equip_item_index > -1 && sd->status.inventory[current_equip_item_index].option[current_equip_opt_index].id) {
|
||||
if (param == ROA_VALUE)
|
||||
script_pushint(st, sd->status.inventory[current_equip_item_index].option[current_equip_opt_index].value);
|
||||
else if (param == ROA_PARAM)
|
||||
script_pushint(st, sd->status.inventory[current_equip_item_index].option[current_equip_opt_index].param);
|
||||
else {
|
||||
ShowWarning("buildin_getrandomoptinfo: Unknown parameter %d.", param);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
switch (param) {
|
||||
case ROA_ID:
|
||||
val = sd->status.inventory[current_equip_item_index].option[current_equip_opt_index].id;
|
||||
break;
|
||||
case ROA_VALUE:
|
||||
val = sd->status.inventory[current_equip_item_index].option[current_equip_opt_index].value;
|
||||
break;
|
||||
case ROA_PARAM:
|
||||
val = sd->status.inventory[current_equip_item_index].option[current_equip_opt_index].param;
|
||||
break;
|
||||
default:
|
||||
ShowWarning("buildin_getrandomoptinfo: Invalid attribute type %d (Max %d).\n", param, MAX_ITEM_RDM_OPT);
|
||||
val = 0;
|
||||
break;
|
||||
}
|
||||
script_pushint(st, val);
|
||||
}
|
||||
else {
|
||||
script_pushint(st, 0);
|
||||
@ -21553,6 +21562,104 @@ BUILDIN_FUNC(getrandomoptinfo) {
|
||||
return SCRIPT_CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a random option on an equipped item.
|
||||
* getequiprandomoption(<equipment indice>,<index>,<type>{,<char id>});
|
||||
* @author [secretdataz]
|
||||
*/
|
||||
BUILDIN_FUNC(getequiprandomoption) {
|
||||
struct map_session_data *sd;
|
||||
int val;
|
||||
short i = -1;
|
||||
int pos = script_getnum(st, 2);
|
||||
int index = script_getnum(st, 3);
|
||||
int type = script_getnum(st, 4);
|
||||
if (!script_charid2sd(5, sd))
|
||||
script_pushint(st, -1);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
if (index < 0 || index >= MAX_ITEM_RDM_OPT) {
|
||||
ShowError("buildin_getequiprandomoption: Invalid random option index %d.\n", index);
|
||||
script_pushint(st, -1);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
if (equip_index_check(pos))
|
||||
i = pc_checkequip(sd, equip_bitmask[pos]);
|
||||
if (i < 0) {
|
||||
ShowError("buildin_getequiprandomoption: No item equipped at pos %d (CID=%d/AID=%d).\n", pos, sd->status.char_id, sd->status.account_id);
|
||||
script_pushint(st, -1);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case ROA_ID:
|
||||
val = sd->status.inventory[i].option[index].id;
|
||||
break;
|
||||
case ROA_VALUE:
|
||||
val = sd->status.inventory[i].option->value;
|
||||
break;
|
||||
case ROA_PARAM:
|
||||
val = sd->status.inventory[i].option->param;
|
||||
break;
|
||||
default:
|
||||
ShowWarning("buildin_getequiprandomoption: Invalid attribute type %d (Max %d).\n", type, MAX_ITEM_RDM_OPT);
|
||||
val = 0;
|
||||
break;
|
||||
}
|
||||
script_pushint(st, val);
|
||||
return SCRIPT_CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a random option on a random option slot on an equipped item and overwrites
|
||||
* existing random option in the process.
|
||||
* setrandomoption(<equipment indice>,<index>,<id>,<value>,<param>{,<char id>});
|
||||
* @author [secretdataz]
|
||||
*/
|
||||
BUILDIN_FUNC(setrandomoption) {
|
||||
struct map_session_data *sd;
|
||||
struct s_random_opt_data *opt;
|
||||
int pos, index, id, value, param, ep;
|
||||
int i = -1;
|
||||
if (!script_charid2sd(7, sd))
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
pos = script_getnum(st, 2);
|
||||
index = script_getnum(st, 3);
|
||||
id = script_getnum(st, 4);
|
||||
value = script_getnum(st, 5);
|
||||
param = script_getnum(st, 6);
|
||||
|
||||
if ((opt = itemdb_randomopt_exists((short)id)) == NULL) {
|
||||
ShowError("buildin_setrandomoption: Random option ID %d does not exists.\n", id);
|
||||
script_pushint(st, 0);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
if (index < 0 || index >= MAX_ITEM_RDM_OPT) {
|
||||
ShowError("buildin_setrandomoption: Invalid random option index %d.\n", index);
|
||||
script_pushint(st, 0);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
if (equip_index_check(pos))
|
||||
i = pc_checkequip(sd, equip_bitmask[pos]);
|
||||
if (i >= 0) {
|
||||
ep = sd->status.inventory[i].equip;
|
||||
log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i]);
|
||||
pc_unequipitem(sd, i, 2);
|
||||
sd->status.inventory[i].option[index].id = id;
|
||||
sd->status.inventory[i].option[index].value = value;
|
||||
sd->status.inventory[i].option[index].param = param;
|
||||
clif_delitem(sd, i, 1, 3);
|
||||
log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i]);
|
||||
clif_additem(sd, i, 1, 0);
|
||||
pc_equipitem(sd, i, ep);
|
||||
script_pushint(st, 1);
|
||||
return SCRIPT_CMD_SUCCESS;
|
||||
}
|
||||
|
||||
ShowError("buildin_setrandomoption: No item equipped at pos %d (CID=%d/AID=%d).\n", pos, sd->status.char_id, sd->status.account_id);
|
||||
script_pushint(st, 0);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
#include "../custom/script.inc"
|
||||
|
||||
// declarations that were supposed to be exported from npc_chat.c
|
||||
@ -22133,6 +22240,8 @@ struct script_function buildin_func[] = {
|
||||
BUILDIN_DEF(recalculatestat,""),
|
||||
BUILDIN_DEF(hateffect,"ii"),
|
||||
BUILDIN_DEF(getrandomoptinfo, "i"),
|
||||
BUILDIN_DEF(getequiprandomoption, "iii?"),
|
||||
BUILDIN_DEF(setrandomoption,"iiiii?"),
|
||||
|
||||
#include "../custom/script_def.inc"
|
||||
|
||||
|
@ -637,7 +637,8 @@ enum navigation_service {
|
||||
};
|
||||
|
||||
enum random_option_attribute {
|
||||
ROA_VALUE = 0,
|
||||
ROA_ID = 0,
|
||||
ROA_VALUE,
|
||||
ROA_PARAM,
|
||||
};
|
||||
/**
|
||||
|
@ -3110,6 +3110,7 @@
|
||||
export_constant(MOBG_ClassChange);
|
||||
|
||||
/* random option attributes */
|
||||
export_constant(ROA_ID);
|
||||
export_constant(ROA_VALUE);
|
||||
export_constant(ROA_PARAM);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user