|
这里附上代码,动手能力强的就直接手动优化吧,没有动手能力的这里也附上傻瓜式一键导入包
function onSetHp_appendage_monster(appendage, hp, attacker) {
if (!appendage) return hp;
local parentObj = appendage.getParent();
local currentHp = hp;
if (!parentObj) return currentHp;
// 如果设置的血量小于 0,可能触发死亡相关逻辑(例如播放声音)
if (hp < 0) {
try {
local object = sq_GetCNRDObjectToActiveObject(parentObj);
if (object) {
local objectIndex = object.getCollisionObjectIndex();
soundList(object, objectIndex);
}
} catch (ex) {
// 捕获异常,防止程序崩溃
}
return hp;
}
// 如果全局变量禁用伤害处理,直接返回
if (ENABLE_DAMAGE_ACTIVE == 0) return hp;
// 计算新造成的伤害
local newHpDamage = parentObj.getHp() - hp;
if (newHpDamage <= 0) return currentHp;
// 检查是否有额外伤害,并更新当前血量
local addHpDamage = appendage.getVar("addHpDamage").getInt(0);
if (addHpDamage > 0) {
currentHp -= addHpDamage;
appendage.getVar("addHpDamage").setInt(0, 0);
return currentHp;
}
// 检查伤害值是否与存储值一致
local hpDamage = appendage.getVar("newHpDamage").getInt(0);
if (newHpDamage == hpDamage) return currentHp;
// 如果攻击者与目标在同一队伍,不处理伤害
if (attacker && (parentObj.getTeam() == attacker.getTeam())) return currentHp;
// 获取目标位置坐标
local x = parentObj.getXPos();
local y = parentObj.getYPos();
local z = parentObj.getObjectHeight() / 2 + CRI_UPPER_HEIGHT;
// 处理特殊技能伤害逻辑
if (SPECIAL_SKILL_FLAG == 1) {
local currTime = appendage.getTimer().Get();
if (currTime - appendage.getVar("atkTimeS").getInt(0) > 500) {
NOMAL_ATTACK_FLAG = 1;
appendage.getVar("atkTimeS").setInt(0, currTime);
currentHp -= applySpecialSkillDamage(appendage, newHpDamage, x, y, z);
}
return currentHp;
}
// **优化的异常状态处理逻辑(合并版)**
local currTime = appendage.getTimer().Get();
local triggered = false;
// 处理感电状态
if (sq_IsValidActiveStatus(parentObj, ACTIVESTATUS_LIGHTNING) &&
currTime - appendage.getVar("lightningTime").getInt(0) > 3000) {
appendage.getVar("lightningTime").setInt(0, currTime);
triggered = true; // 标记感电状态触发
}
// 处理流血状态
if (sq_IsValidActiveStatus(parentObj, ACTIVESTATUS_BLEEDING) &&
currTime - appendage.getVar("bleedingTime").getInt(0) > 1000) {
appendage.getVar("bleedingTime").setInt(0, currTime);
triggered = true; // 标记流血状态触发
}
// 处理中毒状态
if (sq_IsValidActiveStatus(parentObj, ACTIVESTATUS_POISON) &&
currTime - appendage.getVar("poisonTime").getInt(0) > 1500) {
appendage.getVar("poisonTime").setInt(0, currTime);
triggered = true; // 标记中毒状态触发
}
// 处理燃烧状态
if (sq_IsValidActiveStatus(parentObj, ACTIVESTATUS_BURN) &&
currTime - appendage.getVar("burnTime").getInt(0) > 2000) {
appendage.getVar("burnTime").setInt(0, currTime);
triggered = true; // 标记燃烧状态触发
}
// 处理石化状态
if (sq_IsValidActiveStatus(parentObj, ACTIVESTATUS_STONE) &&
currTime - appendage.getVar("stoneTime").getInt(0) > 2500) {
appendage.getVar("stoneTime").setInt(0, currTime);
triggered = true; // 标记石化状态触发
}
// 如果任何异常状态被触发,调用额外伤害函数
if (triggered) {
applyActiveDamage(appendage, newHpDamage, x, y, z);
currentHp -= applyActiveDamage2(newHpDamage);
}
// 检查血量是否低于 1
if (currentHp < 1) currentHp = -1;
return currentHp;
}
如果因为dll和登陆器、服务端、dp插件fr插件的问题导致的闪退,还请自行辨别,判断不了不要上来就说没效果
Base64解码:
aHR0cHM6Ly9wYW4uYmFpZHUuY29tL3MvMURIb2ozTHpoQmRqdlM2UEw3VTdGU1E/cHdkPWY4Z2U= |
|