384 lines
14 KiB
Plaintext
384 lines
14 KiB
Plaintext
/*
|
|
文件名:ExpandEquipment.nut
|
|
路径:Project/ExpandEquipment/ExpandEquipment.nut
|
|
创建日期:2026-01-03 00:29
|
|
文件用途:
|
|
*/
|
|
class ExpandEquipmentC {
|
|
|
|
//回调集合信息
|
|
FuncMapInfo = null;
|
|
//全身装备的ID
|
|
EquipIndexList = null;
|
|
|
|
constructor() {
|
|
FuncMapInfo = {};
|
|
EquipIndexList = {};
|
|
|
|
GenerateEquipmentFunctionMap();
|
|
|
|
RegisterCallback();
|
|
}
|
|
|
|
function Proc(obj) {
|
|
//在副本中 附加AP的逻辑
|
|
if (sq_GetCurrentModuleType() == 3) {
|
|
local appendage = CNSquirrelAppendage.sq_GetAppendage(obj, "appendage/appendage_plugins.nut");
|
|
if (!appendage) {
|
|
CNSquirrelAppendage.sq_AppendAppendage(obj, obj, -1, true, "appendage/appendage_plugins.nut", true);
|
|
}
|
|
} else {
|
|
local appendage = CNSquirrelAppendage.sq_GetAppendage(obj, "appendage/appendage_plugins.nut");
|
|
if (appendage) {
|
|
CNSquirrelAppendage.sq_RemoveAppendage(obj, "appendage/appendage_plugins.nut");
|
|
}
|
|
}
|
|
|
|
//检测身上的装备逻辑
|
|
local ReloadFlag = false;
|
|
local NewEquipList = {};
|
|
for (local i = 1; i< 13; ++i) {
|
|
//编号
|
|
local Index = L_sq_GetCharacterAttribute(0x1c, i);
|
|
if (Index) {
|
|
NewEquipList.rawset(Index, true);
|
|
}
|
|
}
|
|
foreach(Index, _v in NewEquipList) {
|
|
if (!EquipIndexList.rawin(Index)) {
|
|
ReloadFlag = true;
|
|
if (FuncMapInfo.rawin("[on equipment event]")) {
|
|
if (FuncMapInfo["[on equipment event]"].rawin(Index)) {
|
|
local FuncName = FuncMapInfo["[on equipment event]"][Index];
|
|
getroottable()[FuncName](obj, Index);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
foreach(Index, _v in EquipIndexList) {
|
|
if (!NewEquipList.rawin(Index)) {
|
|
ReloadFlag = true;
|
|
if (FuncMapInfo.rawin("[on deequipment event]")) {
|
|
if (FuncMapInfo["[on deequipment event]"].rawin(Index)) {
|
|
local FuncName = FuncMapInfo["[on deequipment event]"][Index];
|
|
getroottable()[FuncName](obj, Index);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (ReloadFlag) {
|
|
ReloadFlag = false;
|
|
EquipIndexList = {};
|
|
GenerateEquipmentFunctionMap();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function RegisterCallback() {
|
|
|
|
_o_procAppend_All_Map_["ExpandEquipmentC"] <- function(obj) {
|
|
if (FuncMapInfo.rawin("[on proc event]")) {
|
|
foreach(Func in FuncMapInfo["[on proc event]"]) {
|
|
getroottable()[Func](obj);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onBeforeAttack_All_Map_["ExpandEquipmentC"] <- function(obj, damager, boundingBox, isStuck) {
|
|
if (FuncMapInfo.rawin("[on before attack event]")) {
|
|
foreach(Func in FuncMapInfo["[on before attack event]"]) {
|
|
getroottable()[Func](obj, damager, boundingBox, isStuck);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onAfterAttack_All_Map_["ExpandEquipmentC"] <- function(obj, damager, boundingBox, isStuck) {
|
|
if (FuncMapInfo.rawin("[on after attack event]")) {
|
|
foreach(Func in FuncMapInfo["[on after attack event]"]) {
|
|
getroottable()[Func](obj, damager, boundingBox, isStuck);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onAttackParent_appendage_plugins_Map_["ExpandEquipmentC"] <- function(appendage, realAttacker, damager, boundingBox, isStuck) {
|
|
if (FuncMapInfo.rawin("[on attack event]")) {
|
|
foreach(Func in FuncMapInfo["[on attack event]"]) {
|
|
getroottable()[Func](appendage, realAttacker, damager, boundingBox, isStuck);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onBeforeDamage_All_Map_["ExpandEquipmentC"] <- function(obj) {
|
|
if (FuncMapInfo.rawin("[on before damage event]")) {
|
|
foreach(Func in FuncMapInfo["[on before damage event]"]) {
|
|
getroottable()[Func](obj);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onDamageParent_appendage_plugins_Map_["ExpandEquipmentC"] <- function(appendage, attacker, boundingBox, isStuck) {
|
|
if (FuncMapInfo.rawin("[on damage event]")) {
|
|
foreach(Func in FuncMapInfo["[on damage event]"]) {
|
|
getroottable()[Func](appendage, attacker, boundingBox, isStuck);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onSetHp_appendage_plugins_Map_["ExpandEquipmentC"] <- function(appendage, hp, attacker) {
|
|
if (FuncMapInfo.rawin("[on set hp event]")) {
|
|
local ret = -1;
|
|
foreach(Func in FuncMapInfo["[on set hp event]"]) {
|
|
ret = getroottable()[Func](appendage, hp, attacker);
|
|
}
|
|
return ret;
|
|
}
|
|
return -1;
|
|
}.bindenv(this);
|
|
|
|
_o_sendSetMpPacket_All_Map_["ExpandEquipmentC"] <- function(obj, mp, sendInstant) {
|
|
if (FuncMapInfo.rawin("[on set mp event]")) {
|
|
foreach(Func in FuncMapInfo["[on set mp event]"]) {
|
|
getroottable()[Func](obj, mp, sendInstant);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onApplyHpDamage_appendage_plugins_Map_["ExpandEquipmentC"] <- function(appendage, newHpDamage, attacker) {
|
|
if (FuncMapInfo.rawin("[on apply damage event]")) {
|
|
local ret = newHpDamage;
|
|
foreach(Func in FuncMapInfo["[on apply damage event]"]) {
|
|
ret = getroottable()[Func](appendage, ret, attacker);
|
|
}
|
|
return ret;
|
|
}
|
|
return newHpDamage;
|
|
}.bindenv(this);
|
|
|
|
_o_getImmuneTypeDamageRate_appendage_plugins_Map_["ExpandEquipmentC"] <- function(appendage, damageRate, attacker) {
|
|
if (FuncMapInfo.rawin("[on immune damage event]")) {
|
|
local ret = damageRate;
|
|
foreach(Func in FuncMapInfo["[on immune damage event]"]) {
|
|
ret = getroottable()[Func](appendage, ret, attacker);
|
|
}
|
|
return ret;
|
|
}
|
|
return damageRate;
|
|
}.bindenv(this);
|
|
|
|
_o_onDestroyObject_appendage_plugins_Map_["ExpandEquipmentC"] <- function(appendage, destroyObj) {
|
|
if (FuncMapInfo.rawin("[on destroy object event]")) {
|
|
local ret = true;
|
|
foreach(Func in FuncMapInfo["[on destroy object event]"]) {
|
|
ret = getroottable()[Func](appendage, destroyObj);
|
|
}
|
|
return ret;
|
|
}
|
|
return true;
|
|
}.bindenv(this);
|
|
|
|
_o_onStartDungeon_All_Map_["ExpandEquipmentC"] <- function(obj) {
|
|
if (FuncMapInfo.rawin("[on start dungeon event]")) {
|
|
foreach(Func in FuncMapInfo["[on start dungeon event]"]) {
|
|
getroottable()[Func](obj);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onStartMap_All_Map_["ExpandEquipmentC"] <- function(obj) {
|
|
if (FuncMapInfo.rawin("[on start map event]")) {
|
|
foreach(Func in FuncMapInfo["[on start map event]"]) {
|
|
getroottable()[Func](obj);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onEndMap_All_Map_["ExpandEquipmentC"] <- function(obj) {
|
|
if (FuncMapInfo.rawin("[on end map event]")) {
|
|
foreach(Func in FuncMapInfo["[on end map event]"]) {
|
|
getroottable()[Func](obj);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_onChangeSkillEffect_All_Map_["ExpandEquipmentC"] <- function(obj, skillIndex, reciveData) {
|
|
if (FuncMapInfo.rawin("[on send effect packet event]")) {
|
|
foreach(Func in FuncMapInfo["[on send effect packet event]"]) {
|
|
getroottable()[Func](obj, skillIndex, reciveData);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_useSkill_before_All_Map_["ExpandEquipmentC"] <- function(obj, skillIndex, consumeMp, consumeItem, oldSkillMpRate) {
|
|
if (FuncMapInfo.rawin("[on before use skill event]")) {
|
|
foreach(Func in FuncMapInfo["[on before use skill event]"]) {
|
|
getroottable()[Func](obj, skillIndex, consumeMp, consumeItem, oldSkillMpRate);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_useSkill_after_All_Map_["ExpandEquipmentC"] <- function(obj, skillIndex, consumeMp, consumeItem, oldSkillMpRate) {
|
|
if (FuncMapInfo.rawin("[on after use skill event]")) {
|
|
foreach(Func in FuncMapInfo["[on after use skill event]"]) {
|
|
getroottable()[Func](obj, skillIndex, consumeMp, consumeItem, oldSkillMpRate);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
_o_setState_All_Map_["ExpandEquipmentC"] <- function(obj, state, datas, isResetTimer) {
|
|
if (FuncMapInfo.rawin("[on set state event]")) {
|
|
foreach(Func in FuncMapInfo["[on set state event]"]) {
|
|
getroottable()[Func](obj, state, datas, isResetTimer);
|
|
}
|
|
}
|
|
}.bindenv(this);
|
|
|
|
|
|
OnSetCharacter_Control["ExpandEquipmentC"] <- function() {
|
|
FuncMapInfo = {};
|
|
GenerateEquipmentFunctionMap();
|
|
}.bindenv(this);
|
|
}
|
|
|
|
// 生成穿戴函数回调
|
|
function GenerateEquipmentFunctionMap() {
|
|
//获取全身装备编号
|
|
EquipIndexList = {};
|
|
for (local i = 1; i< 13; ++i) {
|
|
//编号
|
|
local Index = L_sq_GetCharacterAttribute(0x1c, i);
|
|
if (Index) EquipIndexList.rawset(Index, true);
|
|
}
|
|
|
|
foreach(Index, _v in EquipIndexList) {
|
|
local Info = GetSingleEquipmentInfo(Index);
|
|
if (Info.len() > 0) {
|
|
foreach(FuncType, FuncName in Info) {
|
|
if (!FuncMapInfo.rawin(FuncType)) {
|
|
FuncMapInfo[FuncType] <- {};
|
|
}
|
|
FuncMapInfo[FuncType].rawset(Index, FuncName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// GetSingleEquipmentInfo 回调函数
|
|
function GetSingleEquipmentInfo(Index) {
|
|
local FuncMap = {};
|
|
local FilePath = R_Utils.GetEquPath(Index);
|
|
if (FilePath) {
|
|
FuncMap = Rindro_Script.GetFileData("equipment/" + FilePath, function(DataTable, Data) {
|
|
while (!Data.Eof()) {
|
|
local Fragment = Data.Get();
|
|
if (
|
|
Fragment == "[on equipment event]" ||
|
|
Fragment == "[on deequipment event]" ||
|
|
Fragment == "[on proc event]" ||
|
|
Fragment == "[on before attack event]" ||
|
|
Fragment == "[on attack event]" ||
|
|
Fragment == "[on after attack event]" ||
|
|
Fragment == "[on before damage event]" ||
|
|
Fragment == "[on damage event]" ||
|
|
Fragment == "[on set hp event]" ||
|
|
Fragment == "[on set mp event]" ||
|
|
Fragment == "[on apply damage event]" ||
|
|
Fragment == "[on immune damage event]" ||
|
|
Fragment == "[on start dungeon event]" ||
|
|
Fragment == "[on start map event]" ||
|
|
Fragment == "[on end map event]" ||
|
|
Fragment == "[on send effect packet event]" ||
|
|
Fragment == "[on before use skill event]" ||
|
|
Fragment == "[on after use skill event]" ||
|
|
Fragment == "[on set state event]" ||
|
|
Fragment == "[on destroy object event]"
|
|
) {
|
|
local FuncName = Data.Get();
|
|
DataTable.rawset(Fragment, FuncName);
|
|
}
|
|
}
|
|
});
|
|
FuncMap.rawdelete("filepath");
|
|
}
|
|
return FuncMap;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getroottable().rawdelete("ExpandEquipment_Obj");
|
|
|
|
function Lenheart_ExpandEquipment_Fun(obj) {
|
|
local RootTab = getroottable();
|
|
if (!RootTab.rawin("ExpandEquipment_Obj")) {
|
|
RootTab.rawset("ExpandEquipment_Obj", ExpandEquipmentC());
|
|
}
|
|
RootTab["ExpandEquipment_Obj"].Proc(obj);
|
|
}
|
|
|
|
|
|
|
|
getroottable()["LenheartFuncTab"].rawset("ExpandEquipmentFuncN", Lenheart_ExpandEquipment_Fun);
|
|
|
|
|
|
|
|
/*
|
|
function on_equipment_109000001(Index) {}
|
|
|
|
function on_deequipment_109000001(Index) {}
|
|
|
|
function on_proc_109000001(obj) {}
|
|
|
|
function on_before_attack_109000001(obj, damager, boundingBox, isStuck) {}
|
|
|
|
function on_attack_109000001(appendage, realAttacker, damager, boundingBox, isStuck) {}
|
|
|
|
function on_after_attack_109000001(obj, damager, boundingBox, isStuck) {}
|
|
|
|
function on_before_damage_109000001(obj) {}
|
|
|
|
function on_damage_109000001(appendage, attacker, boundingBox, isStuck) {}
|
|
|
|
function on_set_hp_109000001(appendage, hp, attacker) {}
|
|
|
|
function on_set_mp_109000001(obj, mp, sendInstant) {}
|
|
|
|
function on_apply_damage_109000001(appendage, newHpDamage, attacker) {}
|
|
|
|
function on_immune_damage_109000001(appendage, damageRate, attacker) {}
|
|
|
|
function on_start_dungeon_109000001(obj) {}
|
|
|
|
function on_start_map_109000001(obj) {}
|
|
|
|
function on_end_map_109000001(obj) {}
|
|
|
|
function on_send_effect_packet_109000001(obj, skillIndex, reciveData) {}
|
|
|
|
function on_before_use_skill_109000001(obj, skillIndex, consumeMp, consumeItem, oldSkillMpRate) {}
|
|
|
|
function on_after_use_skill_109000001(obj, skillIndex, consumeMp, consumeItem, oldSkillMpRate) {}
|
|
|
|
function on_set_state_109000001(obj, state, datas, isResetTimer) {}
|
|
|
|
function on_destroy_object_109000001(appendage, destroyObj) {}
|
|
|
|
*/ |