Skip to content
Open
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
33 changes: 33 additions & 0 deletions doc/pandas_events.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,19 @@
如果此时打断后续流程, 那么新穿戴的装备虽然可以成功穿戴,
但是老的装备的"脱下脚本"就不会被触发.

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

*OnPCRefineUIEvent:

使用精炼UI精炼完成后触发事件 [聽風]

携带参数:
@refine_idx 精炼物品的在背包中的序列
@refine_nameid 精炼物品的物品ID
@refine_blessing 精炼是否使用祝福矿石
@refine_success 精炼成功返回 1 否则返回 0

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

//============================================================
// 熊猫模拟器 - 过滤事件 (过滤器事件)
Expand Down Expand Up @@ -849,6 +861,27 @@
@unfavorite_amount 即将移出的道具数量
@unfavorite_idx 即将移出的道具序号 (背包序号)

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

*OnPCRefineUIFilter:

准备使用精炼UI时触发事件, 可通过修改 @refine_rate 变量修改精炼成功率 [聽風]

携带参数:
@refine_idx 精炼物品的在背包中的序列
@refine_nameid 精炼物品的物品ID
@refine_rate 精炼成功概率(可以通过修改这个数值更改成功概率)
@refine_zeny 精炼时消耗的zeny
@refine_cost 精炼时消耗的精炼道具ID
@refine_blessing 精炼是否使用祝福矿石

注意事项:
可以通过脚本指令 refineui_result 来自定义精炼UI

中断说明:
中断后会无视玩家本次精炼道具的请求, 系统不再精炼此装备

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

//============================================================
// 熊猫模拟器 - 实时事件
Expand Down
20 changes: 20 additions & 0 deletions doc/pandas_script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3407,6 +3407,26 @@ NPC名称:

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

refineui_result <背包位置序号>,<动画类型>,<精炼后等级>;

指令用于自定义精炼UI, 播放精炼动画, 并修改物品精炼值 [聽風]

动画类型:
0 - 精炼成功
1 - 精炼失败, 装备消失
2 - 精炼失败, 精炼降级
3 - 精炼失败, 精炼被铁匠的祝福保级

返回值:

注意:
1 - 当 OnPCRefineUIFilter 事件被打断后才可以使用该指令
2 - 精炼成功或精炼失败, 都会将物品精炼等级直接设置为 <精炼后等级>
3 - 此精炼不消耗任何道具, 请使用 delitem 删除精炼材料

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

*setmapflag "<地图名称>",<地图标记常量>{,<参数1>{,<参数2>{,<参数3>{,<参数4>}}}};

该指令在 rAthena 的基础上拓展了更多的参数.
Expand Down
14 changes: 14 additions & 0 deletions src/config/pandas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,11 @@
// 事件类型: Filter / 事件名称: OnPCFavoriteDelFilter
// 常量名称: NPCF_FAVORITE_DEL / 变量名称: favorite_del_filter_name
#define Pandas_NpcFilter_FAVORITE_DEL

// 准备使用精炼UI时触发事件, 可通过修改 @refine_rate 变量修改精炼成功率 [聽風]
// 事件类型: Filter / 事件名称: OnPCRefineUIFilter
// 常量名称: NPCF_REFINEUI / 变量名称: refineui_filter_name
#define Pandas_NpcFilter_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 1>
#endif // Pandas_Struct_Map_Session_Data_EventHalt

Expand Down Expand Up @@ -1539,6 +1544,11 @@
// 事件类型: Event / 事件名称: OnPCUnequipEvent
// 常量名称: NPCE_UNEQUIP / 变量名称: unequip_event_name
#define Pandas_NpcEvent_UNEQUIP

// 使用精炼UI精炼完成后触发事件 [聽風]
// 事件类型: Event / 事件名称: OnPCRefineUIEvent
// 常量名称: NPCE_REFINEUI / 变量名称: refineui_event_name
#define Pandas_NpcEvent_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 7>

/************************************************************************/
Expand Down Expand Up @@ -2234,6 +2244,10 @@
//
// 更多详细用法请移步 doc/pandas_script_commands.txt 文件
#define Pandas_ScriptCommand_GetInventoryList

// 是否启用 refineui_result 脚本指令 [聽風]
// 指令用于自定义精炼UI, 播放精炼动画, 并修改物品精炼值
#define Pandas_ScriptCommand_Refineui_Result
// PYHELP - SCRIPTCMD - INSERT POINT - <Section 1>
#endif // Pandas_ScriptCommands

Expand Down
35 changes: 33 additions & 2 deletions src/map/clif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23424,6 +23424,10 @@ void clif_parse_refineui_refine( int fd, map_session_data* sd ){
uint16 index = server_index( p->index );
t_itemid material = p->itemId;
int16 j;
#ifdef Pandas_NpcEvent_REFINEUI
int refine_success;
int failureid;
#endif // Pandas_NpcEvent_REFINEUI

// Check if the refine UI is open
if( !sd->state.refineui_open ){
Expand Down Expand Up @@ -23530,7 +23534,19 @@ void clif_parse_refineui_refine( int fd, map_session_data* sd ){
if( blacksmith_amount > 0 && pc_delitem( sd, blacksmith_index, blacksmith_amount, 0, 0, LOG_TYPE_CONSUME ) ){
return;
}
#ifdef Pandas_NpcFilter_REFINEUI
pc_setreg(sd, add_str("@refine_idx"), index);
pc_setreg(sd, add_str("@refine_nameid"), item->nameid);
pc_setreg(sd, add_str("@refine_rate"), cost->chance);
pc_setreg(sd, add_str("@refine_zeny"), cost->zeny);
pc_setreg(sd, add_str("@refine_cost"), cost->nameid);
pc_setreg(sd, add_str("@refine_blessing"), (blacksmith_amount > 0) ? 1 : 0);

if (npc_script_filter(sd, NPCF_REFINEUI)) {
return;
}
cost->chance = (int)cap_value(pc_readreg(sd, add_str("@refine_rate")), 0, INT_MAX);
#endif // Pandas_NpcFilter_REFINEUI
// Try to refine the item
if( cost->chance >= ( rnd() % 10000 ) ){
log_pick_pc( sd, LOG_TYPE_OTHER, -1, item );
Expand All @@ -23546,9 +23562,14 @@ void clif_parse_refineui_refine( int fd, map_session_data* sd ){
achievement_update_objective( sd, AG_ENCHANT_SUCCESS, 2, id->weapon_level, item->refine );
}
clif_refineui_info( sd, index );
#ifdef Pandas_NpcEvent_REFINEUI
refine_success = 1;
#endif // Pandas_NpcEvent_REFINEUI
}else{
// Failure

#ifdef Pandas_NpcEvent_REFINEUI
failureid = item->nameid;
#endif // Pandas_NpcEvent_REFINEUI
if (info->broadcast_failure) {
clif_broadcast_refine_result(*sd, item->nameid, item->refine, false);
}
Expand All @@ -23573,7 +23594,17 @@ void clif_parse_refineui_refine( int fd, map_session_data* sd ){

clif_misceffect( &sd->bl, 2 );
achievement_update_objective( sd, AG_ENCHANT_FAIL, 1, 1 );
}
#ifdef Pandas_NpcEvent_REFINEUI
refine_success = 0;
#endif // Pandas_NpcEvent_REFINEUI
}
#ifdef Pandas_NpcEvent_REFINEUI
pc_setreg(sd, add_str("@refine_idx"), index);
pc_setreg(sd, add_str("@refine_nameid"), failureid);
pc_setreg(sd, add_str("@refine_blessing"), (blacksmith_amount > 0) ? 1 : 0);
pc_setreg(sd, add_str("@refine_success"), refine_success);
npc_script_event(sd, NPCE_REFINEUI);
#endif // Pandas_NpcEvent_REFINEUI
#endif
}

Expand Down
3 changes: 3 additions & 0 deletions src/map/clif.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,9 @@ void clif_pvpset(map_session_data *sd, int pvprank, int pvpnum,int type);
void clif_map_property_mapall(int map, enum map_property property);
void clif_refine(int fd, int fail, int index, int val);
void clif_upgrademessage( map_session_data* sd, int result, t_itemid item_id );
#ifdef Pandas_ScriptCommand_Refineui_Result
void clif_refineui_info(map_session_data* sd, uint16 index);
#endif // Pandas_ScriptCommand_Refineui_Result

//petsystem
void clif_catch_process(map_session_data *sd);
Expand Down
14 changes: 14 additions & 0 deletions src/map/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6563,6 +6563,10 @@ bool npc_event_is_filter(enum npce_event eventtype) {
#ifdef Pandas_NpcFilter_FAVORITE_DEL
NPCF_FAVORITE_DEL, // favorite_del_filter_name // OnPCFavoriteDelFilter // 当玩家准备将道具从收藏栏位移出时触发过滤器 [香草]
#endif // Pandas_NpcFilter_FAVORITE_DEL

#ifdef Pandas_NpcFilter_REFINEUI
NPCF_REFINEUI, // refineui_filter_name // OnPCRefineUIFilter // 准备使用精炼UI时触发事件, 可通过修改 @refine_rate 变量修改精炼成功率 [聽風]
#endif // Pandas_NpcFilter_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 20>
};

Expand Down Expand Up @@ -6948,6 +6952,11 @@ const char *npc_get_script_event_name(int npce_index)
case NPCF_FAVORITE_DEL:
return script_config.favorite_del_filter_name; // OnPCFavoriteDelFilter // 当玩家准备将道具从收藏栏位移出时触发过滤器 [香草]
#endif // Pandas_NpcFilter_FAVORITE_DEL

#ifdef Pandas_NpcFilter_REFINEUI
case NPCF_REFINEUI:
return script_config.refineui_filter_name; // OnPCRefineUIFilter // 准备使用精炼UI时触发事件, 可通过修改 @refine_rate 变量修改精炼成功率 [聽風]
#endif // Pandas_NpcFilter_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 3>

/************************************************************************/
Expand Down Expand Up @@ -6988,6 +6997,11 @@ const char *npc_get_script_event_name(int npce_index)
case NPCE_UNEQUIP:
return script_config.unequip_event_name; // OnPCUnequipEvent // 当玩家成功脱下一件装备时触发事件
#endif // Pandas_NpcEvent_UNEQUIP

#ifdef Pandas_NpcEvent_REFINEUI
case NPCE_REFINEUI:
return script_config.refineui_event_name; // OnPCRefineUIEvent // 使用精炼UI精炼完成后触发事件 [聽風]
#endif // Pandas_NpcEvent_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 9>

/************************************************************************/
Expand Down
8 changes: 8 additions & 0 deletions src/map/npc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,10 @@ enum npce_event : uint8 {
#ifdef Pandas_NpcFilter_FAVORITE_DEL
NPCF_FAVORITE_DEL, // favorite_del_filter_name // OnPCFavoriteDelFilter // 当玩家准备将道具从收藏栏位移出时触发过滤器 [香草]
#endif // Pandas_NpcFilter_FAVORITE_DEL

#ifdef Pandas_NpcFilter_REFINEUI
NPCF_REFINEUI, // refineui_filter_name // OnPCRefineUIFilter // 准备使用精炼UI时触发事件, 可通过修改 @refine_rate 变量修改精炼成功率 [聽風]
#endif // Pandas_NpcFilter_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 2>

/************************************************************************/
Expand Down Expand Up @@ -2480,6 +2484,10 @@ enum npce_event : uint8 {
#ifdef Pandas_NpcEvent_UNEQUIP
NPCE_UNEQUIP, // unequip_event_name // OnPCUnequipEvent // 当玩家成功脱下一件装备时触发事件
#endif // Pandas_NpcEvent_UNEQUIP

#ifdef Pandas_NpcEvent_REFINEUI
NPCE_REFINEUI, // refineui_event_name // OnPCRefineUIEvent // 使用精炼UI精炼完成后触发事件 [聽風]
#endif // Pandas_NpcEvent_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 8>

/************************************************************************/
Expand Down
81 changes: 81 additions & 0 deletions src/map/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ struct Script_Config script_config = {
#ifdef Pandas_NpcFilter_FAVORITE_DEL
"OnPCFavoriteDelFilter", // NPCF_FAVORITE_DEL // favorite_del_filter_name // 当玩家准备将道具从收藏栏位移出时触发过滤器 [香草]
#endif // Pandas_NpcFilter_FAVORITE_DEL

#ifdef Pandas_NpcFilter_REFINEUI
"OnPCRefineUIFilter", // NPCF_REFINEUI // refineui_filter_name // 准备使用精炼UI时触发事件, 可通过修改 @refine_rate 变量修改精炼成功率 [聽風]
#endif // Pandas_NpcFilter_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 5>

/************************************************************************/
Expand Down Expand Up @@ -443,6 +447,10 @@ struct Script_Config script_config = {
#ifdef Pandas_NpcEvent_UNEQUIP
"OnPCUnequipEvent", // NPCE_UNEQUIP // unequip_event_name // 当玩家成功脱下一件装备时触发事件
#endif // Pandas_NpcEvent_UNEQUIP

#ifdef Pandas_NpcEvent_REFINEUI
"OnPCRefineUIEvent", // NPCE_REFINEUI // refineui_event_name // 使用精炼UI精炼完成后触发事件 [聽風]
#endif // Pandas_NpcEvent_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 11>

/************************************************************************/
Expand Down Expand Up @@ -33043,6 +33051,76 @@ BUILDIN_FUNC(whodropitem) {
}
#endif // Pandas_ScriptCommand_WhoDropItem

#ifdef Pandas_ScriptCommand_Refineui_Result
/* ===========================================================
* 指令: refineui_result
* 描述: 指令用于自定义精炼UI, 播放精炼动画, 并修改物品精炼值
* 用法: refineui_result <背包位置序号>,<动画类型>,<精炼后等级>;
* 返回: 无
* 作者: 聽風
* -----------------------------------------------------------*/
BUILDIN_FUNC(refineui_result) {
map_session_data* sd;
if (!script_rid2sd(sd))
return SCRIPT_CMD_SUCCESS;
int index = script_getnum(st, 2);
int fail = script_getnum(st, 3);
int val = script_getnum(st, 4);

// 检查 refine UI 是否打开
if (!sd->state.refineui_open) {
return SCRIPT_CMD_SUCCESS;
}

// 检查 idx 是否有效
if (index >= MAX_INVENTORY) {
return SCRIPT_CMD_SUCCESS;
}

// 获取 道具idx
struct item_data* id = sd->inventory_data[index];

// 未找到道具
if (id == NULL) {
return SCRIPT_CMD_SUCCESS;
}

// 检查背包
struct item* item = &sd->inventory.u.items_inventory[index];

// 在背包中找不到该idx的道具
if (item == NULL) {
return SCRIPT_CMD_SUCCESS;
}

// 检查道具是否鉴定
if (!item->identify) {
return SCRIPT_CMD_SUCCESS;
}

// 检查道具是否损坏
if (item->attribute) {
return SCRIPT_CMD_SUCCESS;
}

std::shared_ptr<s_refine_level_info> info = refine_db.findLevelInfo(*id, *item);

// 无法精炼
if (info == nullptr) {
return SCRIPT_CMD_SUCCESS;
}

// No possibilities were found
if (info->costs.empty()) {
return SCRIPT_CMD_SUCCESS;
}

clif_refine(sd->fd, fail, index, val);
clif_refineui_info(sd, index);
return SCRIPT_CMD_SUCCESS;
}
#endif // Pandas_ScriptCommand_Refineui_Result

// PYHELP - SCRIPTCMD - INSERT POINT - <Section 2>

/// script command definitions
Expand Down Expand Up @@ -34039,6 +34117,9 @@ struct script_function buildin_func[] = {
#ifdef Pandas_ScriptCommand_WhoDropItem
BUILDIN_DEF(whodropitem,"v??"), // 查询指定道具会从哪些魔物身上掉落以及掉落的机率信息 [Sola丶小克]
#endif // Pandas_ScriptCommand_WhoDropItem
#ifdef Pandas_ScriptCommand_Refineui_Result
BUILDIN_DEF(refineui_result,"iii"), // 在此写上脚本指令说明 [聽風]
#endif // Pandas_ScriptCommand_Refineui_Result
// PYHELP - SCRIPTCMD - INSERT POINT - <Section 3>

#include <custom/script_def.inc>
Expand Down
8 changes: 8 additions & 0 deletions src/map/script.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ struct Script_Config {
#ifdef Pandas_NpcFilter_FAVORITE_DEL
const char* favorite_del_filter_name; // NPCF_FAVORITE_DEL // OnPCFavoriteDelFilter // 当玩家准备将道具从收藏栏位移出时触发过滤器 [香草]
#endif // Pandas_NpcFilter_FAVORITE_DEL

#ifdef Pandas_NpcFilter_REFINEUI
const char* refineui_filter_name; // NPCF_REFINEUI // OnPCRefineUIFilter // 准备使用精炼UI时触发事件, 可通过修改 @refine_rate 变量修改精炼成功率 [聽風]
#endif // Pandas_NpcFilter_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 4>

/************************************************************************/
Expand Down Expand Up @@ -311,6 +315,10 @@ struct Script_Config {
#ifdef Pandas_NpcEvent_UNEQUIP
const char* unequip_event_name; // NPCE_UNEQUIP // OnPCUnequipEvent // 当玩家成功脱下一件装备时触发事件
#endif // Pandas_NpcEvent_UNEQUIP

#ifdef Pandas_NpcEvent_REFINEUI
const char* refineui_event_name; // NPCE_REFINEUI // OnPCRefineUIEvent // 使用精炼UI精炼完成后触发事件 [聽風]
#endif // Pandas_NpcEvent_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 10>

/************************************************************************/
Expand Down
8 changes: 8 additions & 0 deletions src/map/script_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@
#ifdef Pandas_NpcFilter_FAVORITE_DEL
export_constant(NPCF_FAVORITE_DEL); // favorite_del_filter_name // OnPCFavoriteDelFilter // 当玩家准备将道具从收藏栏位移出时触发过滤器 [香草]
#endif // Pandas_NpcFilter_FAVORITE_DEL

#ifdef Pandas_NpcFilter_REFINEUI
export_constant(NPCF_REFINEUI); // refineui_filter_name // OnPCRefineUIFilter // 准备使用精炼UI时触发事件, 可通过修改 @refine_rate 变量修改精炼成功率 [聽風]
#endif // Pandas_NpcFilter_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 6>

/************************************************************************/
Expand Down Expand Up @@ -168,6 +172,10 @@
#ifdef Pandas_NpcEvent_UNEQUIP
export_constant(NPCE_UNEQUIP); // unequip_event_name // OnPCUnequipEvent // 当玩家成功脱下一件装备时触发事件
#endif // Pandas_NpcEvent_UNEQUIP

#ifdef Pandas_NpcEvent_REFINEUI
export_constant(NPCE_REFINEUI); // refineui_event_name // OnPCRefineUIEvent // 使用精炼UI精炼完成后触发事件 [聽風]
#endif // Pandas_NpcEvent_REFINEUI
// PYHELP - NPCEVENT - INSERT POINT - <Section 12>

/************************************************************************/
Expand Down