找回密码
 点一下
查看: 1888|回复: 15

DotA中小兵攻击顺序的问题

[复制链接]
发表于 2009-4-23 01:22:50 | 显示全部楼层 |阅读模式
DotA中的小兵第一优先攻击正在攻击己方英雄的单位,第二优先攻击红血的单位。请问这是怎么做到的?单纯判断条件A会干扰小兵的移动路线,想了几个办法都不行……
一抹煞白 该用户已被删除
发表于 2009-4-23 08:56:31 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

发表于 2009-4-23 20:16:45 | 显示全部楼层
小兵不会优先攻击红血单位

如果你在对方小兵附近对敌方英雄发动攻击命令,就会使附近的敌方小兵攻击你,前提是敌方小兵短期内没有接受攻击其他英雄的命令
回复

使用道具 举报

 楼主| 发表于 2009-4-24 19:37:06 | 显示全部楼层
引用第1楼一抹煞白于2009-04-23 08:56发表的  :
这个貌似可以起用对战AI吧~自己在对战AI里设置下~
对战AI里没有找到可能产生影响的选项。
能解释得清楚一点吗?
回复

使用道具 举报

发表于 2009-4-24 20:35:45 | 显示全部楼层
貌似ga有这样的演示
回复

使用道具 举报

 楼主| 发表于 2009-4-24 20:40:34 | 显示全部楼层
引用第4楼heris于2009-04-24 20:35发表的  :
貌似ga有这样的演示
这里不就是ga么?
我没有找到这样的演示,能否给个链接呢?
回复

使用道具 举报

一抹煞白 该用户已被删除
发表于 2009-4-24 20:51:02 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

 楼主| 发表于 2009-4-24 21:03:48 | 显示全部楼层
可以了,知道怎么弄了,谢谢……
回复

使用道具 举报

 楼主| 发表于 2009-4-27 01:45:26 | 显示全部楼层
灵异现象:
开空白图拉散兵线测试,AI无比正确。
但是应用到自己做的图里,就没反应了。
难道是对接受了A命令的单位AI不会去指挥?
回复

使用道具 举报

一抹煞白 该用户已被删除
发表于 2009-4-27 12:00:47 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

 楼主| 发表于 2009-4-28 00:55:56 | 显示全部楼层
AI有反应了,但是电脑死活要把兵往家里拉,就是不肯让兵A出去……
只选了主动攻城和没有怜悯
怎么会这样
回复

使用道具 举报

一抹煞白 该用户已被删除
发表于 2009-4-28 11:59:40 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

 楼主| 发表于 2009-4-29 00:18:12 | 显示全部楼层
试了好久,没弄明白……
能不能讲的详细一些?
回复

使用道具 举报

发表于 2009-4-30 17:54:52 | 显示全部楼层
不用试了,DOTA的就是用jass写的,和ai脚本无关
回复

使用道具 举报

发表于 2009-4-30 18:06:40 | 显示全部楼层
[codes=jass]
//===========================================================================
function IsTargetHerosEnemy takes unit target, unit hero returns boolean
    local unit attacker
    if IsUnitEnemy(hero, GetOwningPlayer(target))then
        set attacker = GetStoredUnit(H2S(target), "Attacker")
        if attacker == null or attacker == hero or IsUnitAliveBJ(attacker) == false then
            set attacker = null
            return true
        endif
    endif
    set attacker = null
    return false
endfunction

//===========================================================================
function GetCreepsFilterDisposal takes unit filterUnit, unit attacker returns boolean
    if IsUnitEnemy(filterUnit, GetOwningPlayer(attacker))then
        if GetOwningPlayer(filterUnit) == udg_CreepPlayers[1] or GetOwningPlayer(filterUnit) == udg_CreepPlayers[2] then
            //if GetUnitUserData(filterUnit) == 0 then
                return true
            //endif
        endif
    endif
    return false
endfunction

//===========================================================================
function GetCreepsFilter takes nothing returns boolean
    return GetCreepsFilterDisposal(GetFilterUnit(), udg_attacker)
endfunction

//===========================================================================
function UnitTargetTurnToNormalEnum takes unit enumUnit returns nothing
    call SetUnitUserData(enumUnit, 0)
    call IssueUnitAttackWaypoint(enumUnit, GetUnitCurrentWaypointId(enumUnit))
endfunction

//===========================================================================
function UnitTargetTurnToNormal takes nothing returns nothing
    call UnitTargetTurnToNormalEnum(GetEnumUnit())
endfunction

//===========================================================================
function DefendersTargetTurnToNormal takes group defenders returns nothing
    call ForGroup(defenders, function UnitTargetTurnToNormal)
    call GroupClear(defenders)
endfunction

//===========================================================================   
function DefenderOutOfRangeAttackWaypointEnum takes nothing returns nothing
    if GetUnitCurrentOrder(GetEnumUnit()) == 0 or IsUnitInRange(GetEnumUnit(), udg_attacker, GetUnitAcquireRange(GetEnumUnit())) == false then
        call GroupRemoveUnit(udg_defenders, GetEnumUnit())
        call UnitTargetTurnToNormalEnum(GetEnumUnit())
    endif
endfunction

//===========================================================================
function DefendersAttackAttackerEnum takes nothing returns nothing
    call IssueTargetOrder(GetEnumUnit(), "attack", udg_attacker)
    call GroupAddUnit(udg_defenders, GetEnumUnit())
    call SetUnitUserData(GetEnumUnit(), H2I2(udg_attacker))
endfunction

//===========================================================================
function DefendersBackToNormal takes nothing returns nothing
    local string heroHandle = H2S(GetStoredUnit(H2S(GetExpiredTimer()), "Hero"))
    call StoreHandle(heroHandle, "Attacker", null)
    call DefendersTargetTurnToNormal(GetStoredGroup(heroHandle, "Defenders"))
endfunction

//===========================================================================
function DefineDefendGroup takes unit targetHero, unit attackingHero returns nothing
    local string targetHeroHandle = H2S(targetHero)
    local group defenders = GetStoredGroup(targetHeroHandle, "Defenders")
    local unit attacker = GetStoredUnit(targetHeroHandle, "Attacker")
    local boolexpr b
    local group g
    call PauseTimer(GetStoredTimer(targetHeroHandle, "DefendTimer"))
    if attacker != attackingHero and attacker != null then
        call DefendersTargetTurnToNormal(defenders)
    endif
    call StoreHandle(targetHeroHandle, "Attacker", attackingHero)
    set udg_defenders = defenders
    set udg_attacker = attackingHero
    call ForGroup(defenders, function DefenderOutOfRangeAttackWaypointEnum)
    set b = Filter(function GetCreepsFilter)
    set g = CreateGroup()
    call GroupEnumUnitsInRange(g, GetUnitX(attackingHero), GetUnitY(attackingHero), 500, b)
    call ForGroup(g, function DefendersAttackAttackerEnum)
    call DestroyGroup(g)
    call DestroyBoolExpr(b)
    call TimerStart(GetStoredTimer(targetHeroHandle, "DefendTimer"), 2, false, function DefendersBackToNormal)
    set defenders = null
    set attacker = null
    set b = null
    set g = null
endfunction

//===========================================================================
function OnAttackedConditions takes nothing returns boolean
    return IsTargetHerosEnemy(GetTriggerUnit(), GetAttacker())
endfunction

//===========================================================================
function OnAttackedActions takes nothing returns nothing
    call DefineDefendGroup(GetTriggerUnit(), GetAttacker())
endfunction

//===========================================================================
function OnAttackConditions takes nothing returns boolean
    if IsUnitType(GetOrderTargetUnit(), UNIT_TYPE_HERO) == true and IsUnitIllusion(GetOrderTargetUnit()) == false then
        if GetIssuedOrderId() == 851983 or GetIssuedOrderId() == 851971 then
            if IsUnitVisible(GetTriggerUnit(), GetOwningPlayer(GetOrderTargetUnit()))then
                return IsTargetHerosEnemy(GetOrderTargetUnit(), GetTriggerUnit())
            endif
        endif
    endif
    return false
endfunction

//===========================================================================
function OnAttackActions takes nothing returns nothing
    call DefineDefendGroup(GetOrderTargetUnit(), GetTriggerUnit())
endfunction

//===========================================================================
function UnregisterArmyAiForHero takes unit hero returns nothing
    local string heroHandle = H2S(hero)
    local group g = GetStoredGroup(heroHandle, "Defenders")
    local trigger t = GetStoredTrigger(heroHandle, "OnAttack")
    local timer tm = GetStoredTimer(heroHandle, "DefendTimer")
    call FlushStoredBooleanSimple(heroHandle, "ArmyAIRegistered")
    call DestroyGroup(g)
    call FlushStoredHandle(heroHandle, "Defenders")
    call KillTrigger(t)
    call FlushStoredHandle(heroHandle, "OnAttack")
    set t = GetStoredTrigger(heroHandle, "OnAttacked")
    call KillTrigger(t)
    call FlushStoredHandle(heroHandle, "OnAttacked")
    call FlushStoredMissionSimple(H2S(tm))
    call KillTimer(tm)
    call FlushStoredHandle(heroHandle, "DefendTimer")
    set g = null
    set t = null
    set tm = null
endfunction

//===========================================================================
function RegisterArmyAiForHero takes unit hero returns nothing
    local string heroHandle = H2S(hero)
    local group defenders
    local trigger attackOrderTrigger
    local timer defendTimer
    if GetStoredBooleanSimple(heroHandle, "ArmyAIRegistered") == true then
        return
    endif
    call StoreBooleanSimple(heroHandle, "ArmyAIRegistered", true)
    set defenders = CreateGroup()
    call StoreHandle(heroHandle, "Defenders", defenders)
    set attackOrderTrigger = CreateTrigger()
    call StoreHandle(heroHandle, "OnAttack", attackOrderTrigger)
    call TriggerRegisterUnitEvent(attackOrderTrigger, hero, EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(attackOrderTrigger, Condition(function OnAttackConditions))
    call TriggerAddAction(attackOrderTrigger, function OnAttackActions)
    set attackOrderTrigger = CreateTrigger()
    call StoreHandle(heroHandle, "OnAttacked", attackOrderTrigger)
    call TriggerRegisterUnitEvent(attackOrderTrigger, hero, EVENT_UNIT_ATTACKED)
    call TriggerAddCondition(attackOrderTrigger, Condition(function OnAttackedConditions))
    call TriggerAddAction(attackOrderTrigger, function OnAttackedActions)
    set defendTimer = CreateTimer()
    call StoreHandle(heroHandle, "DefendTimer", defendTimer)
    call StoreHandle(H2S(defendTimer), "Hero", hero)
    set defenders = null
    set attackOrderTrigger = null
    set defendTimer = null
endfunction
[/codes]
回复

使用道具 举报

 楼主| 发表于 2009-4-30 20:35:44 | 显示全部楼层
呃,好吧,谢谢了
好好研究去……
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-11-25 13:46 , Processed in 0.085198 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表