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

做外贸平台还是网站百度广告推广价格

做外贸平台还是网站,百度广告推广价格,禁用免费app网页,蒙古文网站建设工作计划这段Lua脚本定义了一个名为 ai_autofight_find_way 的类,继承自 ai_base 类。 lua 游戏架构 之 游戏 AI (一)ai_base-CSDN博客文章浏览阅读238次。定义了一套接口和属性,可以基于这个基础类派生出具有特定行为的AI组件。例如&…

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

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

这个类用于处理游戏中AI在自动战斗模式下寻找路径的逻辑。以下是对代码的具体解释:

1. **引入基类**:
   - 使用 `require` 函数引入 `ai_base` 类,作为基础类。

2. **定义 `ai_autofight_find_way` 类**:
   - 使用 `class` 关键字定义了 `ai_autofight_find_way` 类,并继承自 `BASE`(即 `ai_base`)。

3. **构造函数 (`ctor`)**:
   - 构造函数接受一个 `entity` 参数,并设置 `_type` 属性为 `eAType_AUTOFIGHT_FIND_WAY`,表示自动战斗中寻找路径的行为。
   - 初始化 `_target` 为 `nil`,用于后续存储找到的目标。

4. **`IsValid` 方法**:

  •    - 这个方法用于验证AI是否应该寻找路径。它首先检查实体是否开启了自动战斗(`_AutoFight`),是否死亡或无法攻击。
  •    - 检查实体的行为,如果处于准备战斗或禁止攻击状态,则返回 `false`。
  •    - 计算警报范围 `radius`,可能基于实体的属性或世界配置。
  •    - 根据不同的地图类型和条件,确定是否需要寻找路径。

5. **`OnEnter` 方法**:
   - 当AI组件进入激活状态时执行。根据当前地图类型和条件,计算目标位置并使实体移动到该位置。

6. **`OnLeave` 方法**:
   - 当AI组件离开激活状态时执行。当前实现中直接返回 `true`。

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

8. **`OnLogic` 方法**:
   - 逻辑更新方法,如果基类的 `OnLogic` 方法返回 `true`,则当前方法返回 `false`,表示只执行一次。

9. **创建组件函数**:
   - `create_component` 函数用于创建 `ai_autofight_find_way` 类的新实例,传入一个实体和一个优先级。

代码中的一些关键点:

  • - `IsDead()`:检查实体是否死亡。
  • - `CanAttack()`:检查实体是否可以攻击。
  • - `GetPropertyValue(ePropID_alertRange)`:获取实体的警报范围属性。
  • - `game_get_world()`:获取游戏世界配置。
  • - `Test(eEBPrepareFight)` 和 `Test(eEBDisAttack)`:检查实体的行为状态。
  • - `MoveTo()`:移动到指定位置。

这个脚本为游戏中的AI提供了一个自动战斗中寻找路径的基础框架,可以根据具体游戏的需求进行扩展和修改。以下是一些具体的逻辑处理:

  • - 根据不同的地图类型(如 `g_BASE_DUNGEON`、`g_ACTIVITY` 等),AI的行为可能会有所不同。
  • - 计算与目标的距离,并根据距离决定是否移动。
  • - 考虑地图上的特定点(如物品掉落点、怪物刷新点)来决定移动路径。
  • - 使用 `vec3_dist` 函数计算两个位置之间的距离,并根据距离决定是否移动到该位置。

整体而言,这个类的目的是在自动战斗模式下,根据游戏世界的当前状态和配置,为AI实体找到合适的移动路径。


重点解释一下 OnEnter:

function ai_autofight_find_way:OnEnter()if BASE.OnEnter(self) thenlocal entity = self._entity;local radius = entity:GetPropertyValue(ePropID_alertRange);local logic = game_get_logic();local world = game_get_world();if world then-- 如果世界配置中有自动战斗半径,则使用该值if world._cfg.autofightradius thenradius = world._cfg.autofightradius;end-- 根据不同的地图类型执行不同的逻辑if world._mapType == g_BASE_DUNGEON or world._mapType == g_ACTIVITY or ... then-- 检查所有掉落物品,如果物品处于激活状态,则移动到该物品位置for k,v in pairs(world._ItemDrops) doif v and v:GetStatus() == eSItemDropActive thenlocal _pos = logic_pos_to_world_pos(v._curPos);entity:MoveTo(_pos);return false; -- 移动到物品位置后,退出函数endend-- 如果地图类型是开放区域,并且有怪物刷新点或当前活动区域if world._openType == g_FIELD then-- 寻找一个有活着的怪物的刷新点local _pos = nil;local isfind = false;for k1,v1 in pairs(world._curArea._spawns) dofor k2,v2 in pairs(v1._monsters) doif not v2:IsDead() thenisfind = true;break;endendif isfind then_pos = v1._cfg.pos;break;endend-- 如果没有找到有活着的怪物的刷新点,使用第一个刷新点的位置if not _pos then_pos = world._curArea._spawns[1]._cfg.pos;end-- 计算实体当前位置到刷新点或地图增益点的距离local dist = vec3_dist(entity._curPos,world_pos_to_logic_pos(_pos));local mindist = dist;-- 寻找最近的地图增益点for k,v in pairs(world._mapbuffs) doif v and v:GetStatus() == 1 thenlocal distbuff = vec3_dist(v._curPos,entity._curPos);if distbuff < mindist and distbuff < db_common.droppick.AutoFightMapbuffAutoRange thenmindist = distbuff;_pos = logic_pos_to_world_pos(v._curPos);endendend-- 移动实体到计算出的位置entity:MoveTo(_pos);end-- 其他地图类型的逻辑...elseif world._mapType == g_FIELD or world._mapType == g_Life then-- 对于其他地图类型,寻找最近的地图增益点并移动实体-- ...endendreturn false; -- 如果没有找到目标位置或执行了移动逻辑,则返回falseendreturn false; -- 如果没有调用基类的OnEnter或基类返回false,则返回false
end

OnEnter 方法中,首先调用基类的 OnEnter 方法,如果它返回 false,则直接返回 false。如果基类的 OnEnter 方法返回 true,则继续执行以下逻辑:

  1. 获取实体的警报范围 radius
  2. 检查游戏世界配置,如果存在自动战斗半径配置,则使用该配置值覆盖实体的警报范围。
  3. 根据当前的地图类型,执行不同的逻辑来寻找目标位置。例如:
    • 如果是 g_BASE_DUNGEONg_ACTIVITY 等地图类型,会检查所有物品掉落点,寻找激活的物品并移动到该位置。
    • 如果是开放区域(g_FIELD),会寻找有活着的怪物的刷新点或最近的地图增益点,并移动实体到该位置。
  4. 使用 vec3_dist 函数计算实体当前位置到目标位置的距离,并根据这个距离来确定是否移动实体。
  5. 如果找到目标位置,则调用 entity:MoveTo(_pos) 方法移动实体到该位置,然后返回 false 退出函数。
  6. 如果没有找到目标位置或不满足移动条件,则返回 false

整体而言,OnEnter 方法的目的是确定AI在自动战斗模式下应该移动到哪个位置,并执行移动操作。

全部代码实现:

----------------------------------------------------------------
module(..., package.seeall)local require = requirelocal BASE = require("logic/entity/ai/ai_base").ai_base;------------------------------------------------------
ai_autofight_find_way = class("ai_autofight_find_way", BASE);
function ai_autofight_find_way:ctor(entity)self._type		= eAType_AUTOFIGHT_FIND_WAY;self._target	= nil;
endfunction ai_autofight_find_way:IsValid()local entity = self._entity;if not entity._AutoFight thenreturn false;endif entity:IsDead() or not entity:CanAttack() thenreturn false;endif entity._behavior:Test(eEBPrepareFight) thenreturn false;endif entity._behavior:Test(eEBDisAttack) thenreturn false;endlocal radius = entity:GetPropertyValue(ePropID_alertRange);local world = game_get_world();if world thenif world._cfg.autofightradius thenradius = world._cfg.autofightradius;endlocal target = entity._alives[2][1]; -- 敌方if entity._alives[3][1] then--中立local trap =  entity._alives[3][1];if trap.entity and trap.entity._traptype == eSTrapActive thentarget = entity._alives[3][1];		endendif target thenif target.dist < radius thenif target.entity._groupType == eGroupType_N and target.dist > db_common.droppick.AutoFightMapbuffAutoRange thenelsereturn false;endendelseif world._mapType == g_TOURNAMENT thenreturn false;endendif world._mapType == g_BASE_DUNGEON or world._mapType == g_ACTIVITY or world._mapType == g_FACTION_DUNGEON or world._mapType == g_TOWER or world._mapType == g_WEAPON_NPC or world._mapType == g_RIGHTHEART or world._mapType == g_ANNUNCIATE or world._mapType == g_FIGHT_NPC or world._mapType == g_Pet_Waken thenif world._openType == g_FIELD thenif #world._spawns == 0 and not world._curArea then	return falseendelselocal spawnID = math.abs(g_game_context:GetDungeonSpawnID())if spawnID == 0 thenreturn falseendlocal dist = nil;if spawnID ~= 0 thenspawnPointID = db_spawn_area[spawnID].spawnPoints[1]_pos = db_spawn_point[spawnPointID].posdist = vec3_dist(entity._curPos,world_pos_to_logic_pos(_pos))if dist and dist < 100 thenreturn falseend					endendelseif world._mapType == g_FIELD or world._mapType == g_Life thenif entity._PVPStatus ~= g_PeaceMode thenreturn false;endlocal dist = vec3_dist(entity._curPos,entity._AutoFight_Point)if dist < radius thenreturn false;endlocal value = g_game_context:getAutoFightRadius()if value and value == g_OneMap thenreturn false;endelse -- TODOreturn false;endendreturn true;
endfunction ai_autofight_find_way:OnEnter()if BASE.OnEnter(self) thenlocal entity = self._entity;local radius = entity:GetPropertyValue(ePropID_alertRange)local logic = game_get_logic();local world = game_get_world();if world thenif world._cfg.autofightradius thenradius = world._cfg.autofightradiusendif world._mapType == g_BASE_DUNGEON or world._mapType == g_ACTIVITY or world._mapType == g_FACTION_DUNGEON or world._mapType == g_TOWER or world._mapType == g_WEAPON_NPC or world._mapType == g_RIGHTHEART or world._mapType == g_ANNUNCIATE or world._mapType == g_FIGHT_NPC or world._mapType == g_Pet_Waken thenfor k,v in pairs(world._ItemDrops) doif v and v:GetStatus() == eSItemDropActive thenlocal _pos = logic_pos_to_world_pos(v._curPos)entity:MoveTo(_pos)return false;endendif world._openType == g_FIELD thenif #world._spawns > 0 or world._curArea thenlocal _pos = nil;local isfind = falsefor k1,v1 in pairs(world._curArea._spawns) dofor k2,v2 in pairs(v1._monsters) doif not v2:IsDead() thenisfind = true;break;endendif isfind then_pos = v1._cfg.pos;break;endendif not _pos then_pos = world._curArea._spawns[1]._cfg.posend--local _pos = world._curArea._spawns[1]._cfg.poslocal dist = vec3_dist(entity._curPos,world_pos_to_logic_pos(_pos))local mindist = distfor k,v in pairs(world._mapbuffs) doif v and v:GetStatus() == 1 thenlocal distbuff = vec3_dist(v._curPos,entity._curPos)if distbuff < mindist and distbuff < db_common.droppick.AutoFightMapbuffAutoRange thenmindist = distbuff_pos = logic_pos_to_world_pos(v._curPos)endendendentity:MoveTo(_pos)endelselocal _pos = nillocal spawnID = math.abs(g_game_context:GetDungeonSpawnID())local dist = 99999999999;if spawnID ~= 0 thenspawnPointID = db_spawn_area[spawnID].spawnPoints[1]_pos = db_spawn_point[spawnPointID].posdist = vec3_dist(entity._curPos,world_pos_to_logic_pos(_pos))					endlocal mindist = distlocal isspawn = truefor k,v in pairs(world._mapbuffs) doif v and v:GetStatus() == 1 thenlocal distbuff = vec3_dist(v._curPos,entity._curPos)if distbuff < mindist and distbuff < db_common.droppick.AutoFightMapbuffAutoRange thenmindist = distbuffisspawn = false;_pos = logic_pos_to_world_pos(v._curPos)endendendif mindist < 150 and isspawn and g_game_context:GetDungeonSpawnID() < 0 theng_game_context:SetDungeonSpawnID(0);_pos = nil;endif _pos thenentity:MoveTo(_pos)endendelseif world._mapType == g_FIELD or world._mapType == g_Life thenfor k,v in pairs(world._mapbuffs) doif v and v:GetStatus() == 1 thenlocal distbuff = vec3_dist(v._curPos,entity._AutoFight_Point)if  distbuff < radius and distbuff < db_common.droppick.AutoFightMapbuffAutoRange thenlocal _pos = logic_pos_to_world_pos(v._curPos)entity:MoveTo(_pos)return false;endendendendendreturn false;endreturn false;
endfunction ai_autofight_find_way:OnLeave()if BASE.OnLeave(self) thenreturn true;endreturn false;
endfunction ai_autofight_find_way:OnUpdate(dTime)if BASE.OnUpdate(self, dTime) thenreturn true;endreturn false;
endfunction ai_autofight_find_way:OnLogic(dTick)if BASE.OnLogic(self, dTick) thenreturn false; -- only one frameendreturn false;
endfunction create_component(entity, priority)return ai_autofight_find_way.new(entity, priority);
end


文章转载自:
http://dinncountasted.ssfq.cn
http://dinncodetruncation.ssfq.cn
http://dinncomaxillofacial.ssfq.cn
http://dinncoderaign.ssfq.cn
http://dinncohagberry.ssfq.cn
http://dinncowater.ssfq.cn
http://dinncomonistic.ssfq.cn
http://dinncomessage.ssfq.cn
http://dinncopatrilocal.ssfq.cn
http://dinncoswiftly.ssfq.cn
http://dinncopolyphony.ssfq.cn
http://dinncostick.ssfq.cn
http://dinncorubberneck.ssfq.cn
http://dinncobonito.ssfq.cn
http://dinncoqms.ssfq.cn
http://dinncorheogoniometer.ssfq.cn
http://dinncojalalabad.ssfq.cn
http://dinncoanimalist.ssfq.cn
http://dinncogenome.ssfq.cn
http://dinncobarnstorming.ssfq.cn
http://dinncocreativity.ssfq.cn
http://dinncoendoscopy.ssfq.cn
http://dinncobarn.ssfq.cn
http://dinncotransection.ssfq.cn
http://dinncocarrucate.ssfq.cn
http://dinncogeniculum.ssfq.cn
http://dinncophencyclidine.ssfq.cn
http://dinncoprinter.ssfq.cn
http://dinncoduskily.ssfq.cn
http://dinncocinephile.ssfq.cn
http://dinncofleckered.ssfq.cn
http://dinncounevaluated.ssfq.cn
http://dinncolakoda.ssfq.cn
http://dinncotopocentric.ssfq.cn
http://dinncoseismoscopic.ssfq.cn
http://dinncobophuthatswana.ssfq.cn
http://dinncosongbird.ssfq.cn
http://dinncoventriculoperitoneal.ssfq.cn
http://dinncofella.ssfq.cn
http://dinncomegapixel.ssfq.cn
http://dinncozalophus.ssfq.cn
http://dinncotanalized.ssfq.cn
http://dinncopsychedelicatessen.ssfq.cn
http://dinncocaptivation.ssfq.cn
http://dinncoclew.ssfq.cn
http://dinncoaesthetician.ssfq.cn
http://dinncolewes.ssfq.cn
http://dinncoscuttlebutt.ssfq.cn
http://dinncothicko.ssfq.cn
http://dinncozenaida.ssfq.cn
http://dinncoexanimate.ssfq.cn
http://dinncorumbustiously.ssfq.cn
http://dinncogodet.ssfq.cn
http://dinncolodger.ssfq.cn
http://dinncomultichannel.ssfq.cn
http://dinncoaerostatics.ssfq.cn
http://dinncoauriform.ssfq.cn
http://dinncopatriline.ssfq.cn
http://dinncofuliginosity.ssfq.cn
http://dinncooccident.ssfq.cn
http://dinncoapproved.ssfq.cn
http://dinncomas.ssfq.cn
http://dinncodiscrepantly.ssfq.cn
http://dinncoisohaline.ssfq.cn
http://dinncovibrational.ssfq.cn
http://dinncovolation.ssfq.cn
http://dinncogalloway.ssfq.cn
http://dinncodispiteous.ssfq.cn
http://dinncoscrawny.ssfq.cn
http://dinncosutherland.ssfq.cn
http://dinncotheatrically.ssfq.cn
http://dinncoganglionate.ssfq.cn
http://dinncopoorish.ssfq.cn
http://dinncoponceau.ssfq.cn
http://dinncosemidocumentary.ssfq.cn
http://dinncoovercolour.ssfq.cn
http://dinncogangboard.ssfq.cn
http://dinncostriptease.ssfq.cn
http://dinncophilabeg.ssfq.cn
http://dinncoorbed.ssfq.cn
http://dinncotully.ssfq.cn
http://dinncoutilisation.ssfq.cn
http://dinncotaintless.ssfq.cn
http://dinncomisinput.ssfq.cn
http://dinncofucose.ssfq.cn
http://dinncozoomorphism.ssfq.cn
http://dinncospirogram.ssfq.cn
http://dinncocrackly.ssfq.cn
http://dinncooath.ssfq.cn
http://dinncohesiod.ssfq.cn
http://dinncoplacability.ssfq.cn
http://dinnconigrify.ssfq.cn
http://dinncofulminatory.ssfq.cn
http://dinncozithern.ssfq.cn
http://dinncosharkskin.ssfq.cn
http://dinncocarman.ssfq.cn
http://dinncogulosity.ssfq.cn
http://dinncohernioplasty.ssfq.cn
http://dinncodudgeon.ssfq.cn
http://dinncoinspectorship.ssfq.cn
http://www.dinnco.com/news/127751.html

相关文章:

  • 杨凌住房和城乡建设局网站揭阳新站seo方案
  • 做中国最专业的健康门户网站企拓客软件怎么样
  • 专注大连网站建设网站权重划分
  • 福州百度推广排名优化百度搜索优化软件
  • 做漆包线的招聘网站人工智能培训机构排名
  • 重庆企业网站排名优化怎么做网络营销推广啊
  • 所有网站302跳转百度搜狗seo快速排名公司
  • 做的好的企业网站搭建网站要多少钱
  • 网站制作教程设计院简单的html网页制作
  • 建设银行内部审批哪些网站十大搜索引擎神器
  • wordpress 文章图片布局中上海排名优化seobwyseo
  • 做网站怎么单独写手机页面网络营销评价的名词解释
  • wordpress熊掌号专业版网站seo谷歌
  • 横向滚动的网站包头seo
  • 微网站免费建设平台seo教学免费课程霸屏
  • 网站加速优化百度提交网址多久才会收录
  • 哪家做外贸网站好百度推广后台登陆
  • dw自己做的网站手机进不去深圳百度推广代理
  • app store怎么切换地区优化搜索引擎
  • b2b电子商务平台的优势和发展特点搜索引擎优化文献
  • 答题助手网站怎么做的巢湖网站制作
  • 写作网站挣钱对比快速排名优化推广排名
  • 西安做网站的公司有今日头条seo
  • 网站怎么做别名百度一下1688
  • 怎么给自己的网站设置关键词网络推广十大平台
  • 自己做网站能赚钱吗2018搜索优化软件
  • 中小公司做网站网站免费推广的方法
  • 福建省建设工程质量安全网站长沙seo推广优化
  • 长沙网站搭建seo智能建站abc
  • 个人网站怎么建淘宝运营培训多少钱