Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented basic script commands to apply options to equipped item.
- Loading branch information
Jittapan Pluemsumran
committed
Aug 15, 2016
1 parent
da21013
commit 8deabb1
Showing
5 changed files
with
161 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21536,23 +21536,130 @@ 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); | ||
} | ||
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; | ||
This comment has been minimized.
Sorry, something went wrong.
cydh
Contributor
|
||
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]); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
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" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 8deabb1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is <equipment indice>
? (if typo, shouldn't it index or indices?)
Maybe, did u mean is <equipment slot>
?
If just by reading this doc, still, don't get what is param and value mean,