当前位置: 首页 > news >正文

做网站用哪里的服务器比较好百度风云榜小说榜排名

做网站用哪里的服务器比较好,百度风云榜小说榜排名,自己设计小程序,高端网站建设企业这段Lua脚本定义了一个名为 ai_attack 的类,继承自 ai_base 类。 lua 游戏架构 之 游戏 AI (一)ai_base-CSDN博客文章浏览阅读119次。定义了一套接口和属性,可以基于这个基础类派生出具有特定行为的AI组件。例如,可以…

这段Lua脚本定义了一个名为 `ai_attack` 的类,继承自 `ai_base` 类。

lua 游戏架构 之 游戏 AI (一)ai_base-CSDN博客文章浏览阅读119次。定义了一套接口和属性,可以基于这个基础类派生出具有特定行为的AI组件。例如,可以创建追逐敌人的AI、巡逻的AI或使用特定策略的AI等,都继承自这个基础类https://blog.csdn.net/heyuchang666/article/details/140624481?spm=1001.2014.3001.5501

这个类用于处理游戏中AI的攻击逻辑。以下是对代码的详细解释:

1. **引入基类**:
   - `local BASE = require("logic/entity/ai/ai_base").ai_base;` 这行代码引入了基类 `ai_base`。

2. **定义 `ai_attack` 类**:
   - `ai_attack = class("ai_attack", BASE);` 这行代码定义了 `ai_attack` 类并指定其基类为 `BASE`。

3. **构造函数 (`ctor`)**:
   - `function ai_attack:ctor(entity)` 构造函数接受一个 `entity` 参数,并设置 `_type` 属性为 `eAType_ATTACK`。

4. **`IsValid` 方法**:
   - 这个方法用于验证AI是否可以执行攻击。它检查实体是否死亡、是否可以攻击、是否是特定类型的实体等条件。

5. **`CanAttackNoneTarget` 方法**:
   - 这个方法用于判断是否可以攻击没有目标的情况,当前实现返回 `false`。

6. **`OnEnter` 方法**:
   - 当AI组件进入激活状态时执行。该方法处理目标定位、实体朝向调整、攻击开始逻辑等。
   - 如果实体有目标并且速度大于0,则计算目标和实体之间的旋转角度,并设置实体面向目标。

7. **`OnLeave` 方法**:
   - 当AI组件离开激活状态时执行。该方法处理停止攻击的逻辑,并恢复实体的移动能力。

8. **`OnUpdate` 方法**:
   - 每帧调用,用于更新AI状态。如果基类的 `OnUpdate` 方法返回 `false`,则当前方法也返回 `false`。

9. **`OnLogic` 方法**:
   - 逻辑更新方法,用于处理技能序列、检查攻击持续时间等。
   - 如果技能序列有效且是当前技能的子技能,则执行相关逻辑。
   - 检查自攻击开始以来的时间是否已经超过技能的持续时间,如果是,则返回 `false`。

10. **创建组件函数**:
    - `function create_component(entity, priority)` 这个函数用于创建 `ai_attack` 类的新实例,传入一个实体和一个优先级。

代码中的一些关键函数和方法:
- `IsDead()`:检查实体是否死亡。
- `CanAttack()`:检查实体是否可以攻击。
- `GetEntityType()`:获取实体的类型。
- `GetMapEnter()`:获取地图进入的状态。
- `Test(eEBAttack)`:测试实体的行为是否包含攻击行为。
- `CanUse()`:检查技能是否可以使用。
- `IsPlayer()`:检查目标是否是玩家。
- `GetRadius()`:获取实体的半径。
- `vec3_sub1()`:计算两个向量的差。
- `vec3_len()`:计算向量的长度。
- `vec3_angle1()`:计算两个向量之间的夹角。
- `SetFaceDir()`:设置实体的面向方向。
- `StartAttack()`:开始攻击。
- `StopAttack()`:停止攻击。
- `FinishAttack()`:完成攻击。

这个脚本为游戏中的AI提供了一个攻击行为的基础框架,可以根据具体游戏的需求进行扩展和修改。

----------------------------------------------------------------local require = requirelocal BASE = require("logic/entity/ai/ai_base").ai_base;------------------------------------------------------
ai_attack = class("ai_attack", BASE);
function ai_attack:ctor(entity)self._type = eAType_ATTACK;
endfunction ai_attack:IsValid()local entity = self._entity;if entity:IsDead() or not entity:CanAttack() thenreturn false;endif entity:GetEntityType() == eET_Player and entity._DigStatus == 2 thenreturn false;endif entity:GetEntityType() == eET_Trap thenif entity._ntype ~= eEntityTrapType_AOE thenreturn false;elseif entity._curSkill and entity._curSkill:CanUse() thenreturn trueendendendif not g_game_context:GetMapEnter() thenreturn false;endif entity._behavior:Test(eEBAttack) thenreturn true;endif entity._curSkill and entity._curSkill:CanUse() thenlocal target = entity._target;if target thenif not target:IsPlayer() and target:GetEntityType() == eET_Player thenif target._behavior:Test(eEBInvisible) thenreturn false;endendlocal dist = vec3_sub1(entity._curPos, target._curPos);if (entity._curSkill._range + (entity:GetRadius() + target:GetRadius())) > vec3_len(dist) thenreturn true;endreturn false;elseif entity:GetEntityType() == eET_Player then if entity._AutoFight thenreturn falseendelseif entity:GetEntityType() == eET_Mercenary thenif entity._cfg.ultraSkill == entity._curSkill._id thenreturn trueendif entity._curSkill._specialArgs.rushInfo and not entity._hoster:IsPlayer() thenreturn trueendendendreturn self:CanAttackNoneTarget();endreturn false;
endfunction ai_attack:CanAttackNoneTarget()return false;
endfunction ai_attack:OnEnter()if BASE.OnEnter(self) thenlocal entity = self._entity;local target = entity._target;local speed = entity:GetPropertyValue(ePropID_speed);if speed > 0 and entity._target and entity._target._guid ~= entity._guid thenlocal p1 = target._curPos;local p2 = entity._curPos;local rot_y = vec3_angle1(p1, p2, { x = 1, y = 0, z = 0 });entity:SetFaceDir(0, rot_y, 0);endself._startTick	= game_get_logic_time();self._skill		= entity._curSkill;self._canBreak	= self._skill._canBreak;self._duration	= self._skill._duration;self._attacker	= entity:StartAttack();self._movable = entity._movable;if not self._attacker thenreturn false;endself._entity._movable = false;return true;endreturn false;
endfunction ai_attack:OnLeave()if BASE.OnLeave(self) thenif self._canBreak and self._attacker thenself._attacker:StopAttack(false);endself._entity:FinishAttack();self._entity._movable = self._movable;return true;endreturn false;
endfunction ai_attack:OnUpdate(dTime)if not BASE.OnUpdate(self, dTime) then return false; endreturn true;
endfunction ai_attack:OnLogic(dTick)if not BASE.OnLogic(self, dTick) then return false; endlocal seq_skill = self._entity._seq_skill;if seq_skill and seq_skill.valid and seq_skill.parent == self._skill thenseq_skill.valid = false;if self._attacker thenif self._attacker:NextSequence(seq_skill.skill) thenself._duration	= seq_skill.skill._duration;self._startTick	= game_get_logic_time();endendendif self._skill thenif (game_get_logic_time() - self._startTick) * 1000 >= self._duration thenreturn false;endendreturn true;
endfunction create_component(entity, priority)return ai_attack.new(entity, priority);
end


 

http://www.khdw.cn/news/18888.html

相关文章:

  • 网站建设贵不贵seo发贴软件
  • 营销型网站的分类网络营销最新案例
  • 一个网站怎么绑定很多个域名成都seo网络优化公司
  • 家具行业建设网站seo引擎搜索
  • 泰州做网站哪家好网站地址ip域名查询
  • 免费移动网站建设网络广告一般是怎么收费
  • 给公司做网站诈骗免费网站统计代码
  • 自建博客网站网页点击量统计
  • 企业crm销售管理系统大连网络营销seo
  • 秦皇岛网站制作服务云南疫情最新情况
  • 软件开发的工作如何做好seo基础优化
  • 机关单位特色的网站建设公司业务推广
  • 内蒙网站建设seo优化厦门seo蜘蛛屯
  • 网站开发前端框架和后端框架郑州seo推广优化
  • 如何用ps做网站百度地图导航网页版
  • 网页游戏网站官网百度云官网登录入口
  • 个人求职网站设计网络营销案例分析题及答案
  • 无极官方网站下载深圳seo优化排名
  • 我也来做外国网站购物百度网络优化推广公司
  • 房门户网站如何做优化襄阳seo
  • 做网站企业经营范围seo网络排名优化方法
  • 网站建设中布局搜索引擎技术
  • 龙岩网上房地产邯郸seo推广
  • 怎样做网站的后台广州市新闻最新消息
  • 阿里网站建设教程seo优化推广业务员招聘
  • b2b行业网站程序百度手机
  • swf影视网站源码石家庄自动seo
  • 安徽城乡建设局网站小企业广告投放平台
  • 海宁营销型网站设计sem电子扫描显微镜
  • 做网站 需要注意什么贵州seo培训