啊丹 发表于 2006-4-3 08:32:34

[Izualizm]让电脑控制的英雄自动学习技能

Melee里的英雄会学习技能, 但是custom里似乎不会. 用Hero - Learn Skill又无法学习自定义技能, 也无法和英雄目前的等级对应起来..

这个办法需要你先制定几种不同的学习顺序, 再在trigger编辑器里创建一个技能数组, 我这里叫ab_iSkills, 下面代码橙色部分可以换成自己的, 棕色是注释, 整个函数必须粘贴到trigger编辑器最上面的 xxx.w3x 里.

function IzualizmSkills takes nothing returns nothing
// 把自定义的4种技能存入变量, A005是终极技能, 6级后才能学到
// A00x这些是技能ID~~
local integer BaQiSi = 'A002'
local integer TJJTDS = 'A003'
local integer WeiSuoAura = 'A001'
local integer BTwave = 'A005'

// 两种顺序各50%几率
if ( ( GetRandomInt(1, 100) > 50 ) ) then
// ------------------------------------------------------------------------
// 顺序1
set udg_ab_iSkills[ 1] = BaQiSi
set udg_ab_iSkills[ 2] = TJJTDS
set udg_ab_iSkills[ 3] = BaQiSi
set udg_ab_iSkills[ 4] = WeiSuoAura
set udg_ab_iSkills[ 5] = BaQiSi
set udg_ab_iSkills[ 6] = BTwave
set udg_ab_iSkills[ 7] = TJJTDS
set udg_ab_iSkills[ 8] = TJJTDS
set udg_ab_iSkills[ 9] = WeiSuoAura
set udg_ab_iSkills = WeiSuoAura
else
// 顺序2
set udg_ab_iSkills[ 1] = BaQiSi
set udg_ab_iSkills[ 2] = WeiSuoAura
set udg_ab_iSkills[ 3] = BaQiSi
set udg_ab_iSkills[ 4] = TJJTDS
set udg_ab_iSkills[ 5] = BaQiSi
set udg_ab_iSkills[ 6] = BTwave
set udg_ab_iSkills[ 7] = TJJTDS
set udg_ab_iSkills[ 8] = TJJTDS
set udg_ab_iSkills[ 9] = WeiSuoAura
set udg_ab_iSkills = WeiSuoAura
endif
endfunction

一级的英雄有1点技能, 所以做个trigger对应一级英雄 (我这里的事件是当玩家雇佣了英雄时)

Events
Unit - A unit owned by Neutral Passive Sells a unit
Conditions
(Unit-type of (Sold unit)) Equal to Izualizm
(Unspent skill points of (GetSoldUnit())) Greater than or equal to 1
Actions
Custom script: local integer abFirstTemp
Custom script: local integer abFirstTempIndex = GetHeroLevel(GetSoldUnit()) - GetHeroSkillPoints(GetSoldUnit())
Custom script: set bj_forLoopAIndex = 1
Custom script: set bj_forLoopAIndexEnd = GetHeroSkillPoints(GetSoldUnit())
Custom script: call IzualizmSkills()
Custom script: loop
Custom script: exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
Custom script: set abFirstTemp = udg_ab_iSkills
Custom script: set bj_forLoopAIndex = bj_forLoopAIndex + 1
Custom script: endloop

上面这句等价于

Events
Unit - A unit owned by Neutral Passive Sells a unit
Conditions
(Unit-type of (Sold unit)) Equal to Izualizm
(Unspent skill points of (Sold unit)) Greater than or equal to 1
Actions
For each (Integer A) from 1 to (Unspent skill points of (Sold unit)), do (Actions)
Loop - Actions
Hero - Learn skill for (Sold unit): ab_iSkills[ ( Hero Level of (Sold unit) - (Unspent skill points of (Sold unit)) ) + IntegerA]

平时(1级以后)就用这个trigger

Events
Unit - A unit owned by Player 1 (Red) Gains a level
Conditions
(Unit-Type of (Leveling Hero)) Equal to Izualizm
(Unspent skill points of (Leveling Hero)) Greater than or equal to 1
Actions
Custom script: local integer abTemp
Custom script: local integer abTempIndex = GetHeroLevel(GetLevelingUnit()) - GetHeroSkillPoints(GetLevelingUnit())
Custom script: set bj_forLoopAIndex = 1
Custom script: set bj_forLoopAIndexEnd = GetHeroSkillPoints(GetLevelingUnit())
Custom script: loop
Custom script: exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
Custom script: set abTemp = udg_ab_iSkills
Custom script: set bj_forLoopAIndex = bj_forLoopAIndex + 1
Custom script: endloop

等价于

Events
Unit - A unit owned by Player 1 (Red) Gains a level
Conditions
(Unit-type of (Leveling Hero)) Equal to Izualizm
(Unspent skill points of (Leveling Hero)) Greater than or equal to 1
Actions
For each (Integer A) from 1 to (Unspent skill points of (Leveling Hero)), do (Actions)
Loop - Actions
Hero - Learn skill for (Leveling Hero): ab_iSkills[ ( Hero Level of (Leveling Hero) - (Unspent skill points of (Leveling Hero)) ) + IntegerA]
页: [1]
查看完整版本: [Izualizm]让电脑控制的英雄自动学习技能