11111
This commit is contained in:
190
Project/Fiendwar copy/FiendFightLogic.nut
Normal file
190
Project/Fiendwar copy/FiendFightLogic.nut
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
文件名:FiendFightLogic.nut
|
||||
路径:Plugins/Fiendwar/FiendFightLogic.nut
|
||||
创建日期:2024-05-27 19:18
|
||||
文件用途:超时空战斗逻辑
|
||||
*/
|
||||
class FiendFightLogicC {
|
||||
//进入BOSS房间发包告诉服务端的Flag
|
||||
IsBossActiveMsgPackFlag = false;
|
||||
|
||||
constructor() {
|
||||
|
||||
//注册回调包
|
||||
Pack_Control.rawset(20063030, SetCharacterDamageRate.bindenv(this));
|
||||
Pack_Control.rawset(20063600, CreatePassiveObjectById.bindenv(this));
|
||||
Pack_Control.rawset(20063602, GetBossHp.bindenv(this));
|
||||
Pack_Control.rawset(20063604, SetBossHp.bindenv(this));
|
||||
Pack_Control.rawset(20063608, CheckMonsterIsV.bindenv(this));
|
||||
}
|
||||
|
||||
//检测怪物是否存在
|
||||
function CheckMonsterIsV(Chunk) {
|
||||
if (!IsBossActiveMsgPackFlag) return;
|
||||
local Jso = Json.Decode(Chunk);
|
||||
local Idx = Jso.id;
|
||||
local ObjectBuf = GetObjectByIndex(Idx);
|
||||
if (!ObjectBuf) {
|
||||
local T = {
|
||||
op = 20063609,
|
||||
id = Idx
|
||||
}
|
||||
Rindro_BaseToolClass.SendPack(T);
|
||||
}
|
||||
}
|
||||
|
||||
//设置BOSS生命值
|
||||
function SetBossHp(Chunk) {
|
||||
if (!IsBossActiveMsgPackFlag) return;
|
||||
local Jso = Json.Decode(Chunk);
|
||||
local BossObject = GetObjectByIndex(210994);
|
||||
|
||||
//没找到BOSS
|
||||
if (!BossObject) {
|
||||
local T = {
|
||||
op = 20063605,
|
||||
}
|
||||
Rindro_BaseToolClass.SendPack(T);
|
||||
} else {
|
||||
BossObject.setHp(Jso.hp, null, true);
|
||||
}
|
||||
|
||||
}
|
||||
//获取BOSS生命值
|
||||
function GetBossHp(Chunk) {
|
||||
if (!IsBossActiveMsgPackFlag) return;
|
||||
local BossObject = GetObjectByIndex(210994);
|
||||
local curthp = -1;
|
||||
local rmaxhp = -1;
|
||||
//找到BOSS
|
||||
if (BossObject) {
|
||||
curthp = BossObject.getHp();
|
||||
rmaxhp = BossObject.getHpMax();
|
||||
}
|
||||
|
||||
local T = {
|
||||
op = 20063603,
|
||||
hp = curthp,
|
||||
maxhp = rmaxhp
|
||||
}
|
||||
Rindro_BaseToolClass.SendPack(T);
|
||||
}
|
||||
|
||||
//设置伤害值回调
|
||||
function SetCharacterDamageRate(Chunk) {
|
||||
local Jso = Json.Decode(Chunk);
|
||||
local Rate = Jso.damageMarkup.tofloat() / 100.0;
|
||||
//超时空伤害设置
|
||||
if (getroottable().rawin("LenheartFiendModuleDamageRate")) {
|
||||
getroottable()["LenheartFiendModuleDamageRate"] = Rate;
|
||||
}
|
||||
}
|
||||
|
||||
//召唤PassiveObject回调
|
||||
function CreatePassiveObjectById(Chunk) {
|
||||
local Jso = Json.Decode(Chunk);
|
||||
local ObjectId = Jso.id;
|
||||
local ZPos = Jso.z;
|
||||
|
||||
//确保在BOSS房间才召唤免得游戏崩溃
|
||||
if (IsBossActiveMsgPackFlag) {
|
||||
local obj = sq_GetMyMasterCharacter();
|
||||
obj = sq_GetCNRDObjectToActiveObject(obj);
|
||||
// obj.sq_SendCreatePassiveObjectPacket(ObjectId, 0, 99999990, 0, ZPos);
|
||||
// sq_SendCreatePassiveObjectPacketFromPassivePos(obj, ObjectId, 0, 99999990, 0, ZPos);
|
||||
sq_SendCreatePassiveObjectPacket(obj, ObjectId, 0, 99999990, 0, ZPos, obj.getDirection());
|
||||
local Jso = {
|
||||
op = 20063601,
|
||||
id = ObjectId,
|
||||
z = ZPos
|
||||
}
|
||||
Rindro_BaseToolClass.SendPack(Jso);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//获取指定对象
|
||||
function GetObjectByIndex(Idx) {
|
||||
local obj = sq_GetMyMasterCharacter();
|
||||
obj = sq_GetCNRDObjectToActiveObject(obj);
|
||||
local objectManager = obj.getObjectManager();
|
||||
local CollisionObjectNumber = objectManager.getCollisionObjectNumber();
|
||||
for (local i = 0; i< CollisionObjectNumber; i += 1) {
|
||||
local object = objectManager.getCollisionObject(i);
|
||||
if (object && object.isObjectType(OBJECTTYPE_ACTIVE)) {
|
||||
local activeObj = sq_GetCNRDObjectToActiveObject(object);
|
||||
local MonsterIndex = activeObj.getCollisionObjectIndex();
|
||||
if (MonsterIndex == Idx) {
|
||||
return activeObj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//获取地图ID
|
||||
function GetMapIndex() {
|
||||
local stage = sq_GetGlobaludpModuleStage();
|
||||
local MapIndex = sq_GetMapIndex(stage);
|
||||
return MapIndex;
|
||||
}
|
||||
|
||||
//检测是否在超时空BOSS图
|
||||
function CheckBossIsActive() {
|
||||
//如果在副本中
|
||||
if (sq_GetCurrentModuleType() == 3) {
|
||||
//在BOSS地图
|
||||
if (GetMapIndex() == 24151) {
|
||||
if (!IsBossActiveMsgPackFlag) {
|
||||
IsBossActiveMsgPackFlag = true;
|
||||
local Jso = {
|
||||
op = 20063801
|
||||
}
|
||||
Rindro_BaseToolClass.SendPack(Jso);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//退出副本以后设置flag 还原
|
||||
else {
|
||||
IsBossActiveMsgPackFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//怪物死亡回调包
|
||||
function MonsterDieCallBack(obj) {
|
||||
//遍历怪物死亡
|
||||
local objectManager = obj.getObjectManager();
|
||||
local CollisionObjectNumber = objectManager.getCollisionObjectNumber();
|
||||
for (local i = 0; i< CollisionObjectNumber; i += 1) {
|
||||
local object = objectManager.getCollisionObject(i);
|
||||
if (object && object.isObjectType(OBJECTTYPE_ACTIVE) && obj.isEnemy(object) && object.isInDamagableState(obj) && object.getTeam() != 0) {
|
||||
local activeObj = sq_GetCNRDObjectToActiveObject(object);
|
||||
if (activeObj.isDead()) {
|
||||
local MonsterIndex = activeObj.getCollisionObjectIndex();
|
||||
if (MonsterIndex >= 210994 && MonsterIndex <= 210999) {
|
||||
local Jso = {
|
||||
op = 20063503,
|
||||
monster_id = MonsterIndex
|
||||
}
|
||||
Rindro_BaseToolClass.SendPack(Jso);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Proc(obj) {
|
||||
|
||||
//如果进入BOSS房间需要告诉服务端
|
||||
CheckBossIsActive();
|
||||
|
||||
//如果在和BOSS干架 要检测所有怪物的死亡
|
||||
if (IsBossActiveMsgPackFlag) {
|
||||
//怪物死亡检测
|
||||
MonsterDieCallBack(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user