|
发表于 2008-1-18 08:57:26
|
显示全部楼层
如果有兴趣,且不嫌我的代码太乱的话,看看这个吧,或许有些帮助.
//这里面多数函数非标准函数,都是我自己的函数库中提供的...
不过意思明显,也很好猜出来.
[codes=jass]
//! import zhuzhu.j
function add_timed_ability takes nothing returns nothing
//读取数据: 英雄,光环影响单位组,魔法书,真正技能,范围,友敌,等级
local unit zhuzhu_aura_hero=GetTimerUnit("aura_hero")
local group zhuzhu_aura_group=GetTimerGroup("aura_group")
local integer book=GetTimerInt("aura_book")
local integer abilityid=GetTimerInt("aura_abilityid")
local integer buffability=GetTimerInt("buffability")
local real zhuzhu_aura_r=GetTimerReal("aura_r")
local boolean allay=GetTimerBool("aura_allay")
local integer aura_level=GetTimerInt("aura_level")
local real unit_x=GetUnitX(zhuzhu_aura_hero)
local real unit_y=GetUnitY(zhuzhu_aura_hero)
//把周围没有进行设置的单位移入影响单位组中,并添加技能
set gt_group=CreateGroup()
call GroupEnumUnitsInRange(gt_group,unit_x,unit_y,zhuzhu_aura_r,null)
loop
set gt_unit=FirstOfGroup(gt_group)
exitwhen gt_unit==null
call GroupRemoveUnit(gt_group,gt_unit)
//只对没有被标记的英雄处理
if GetInt(gt_unit,I2S(abilityid))==0 then
if IsPlayerAlly( GetOwningPlayer(gt_unit),GetOwningPlayer(zhuzhu_aura_hero))==allay and GetInt(gt_unit,I2S(abilityid))<=0 then
call GroupAddUnit(zhuzhu_aura_group,gt_unit)
call UnitAddAbility(gt_unit,book)
call UnitAddAbility(gt_unit,abilityid)
call UnitAddAbility(gt_unit,buffability)
endif
if IsPlayerAlly( GetOwningPlayer(gt_unit),GetOwningPlayer(zhuzhu_aura_hero) )==allay then
call SetUnitAbilityLevel(gt_unit,abilityid,aura_level)
call SetUnitAbilityLevel(gt_unit,buffability,aura_level)
call SetInt(gt_unit,I2S(abilityid),3)
endif
endif
endloop
call DestroyGroup(gt_group)
set gt_group=CloneGroup(zhuzhu_aura_group)
loop
set gt_unit=FirstOfGroup(gt_group)
exitwhen gt_unit==null
if GetInt(gt_unit,I2S(abilityid))<=0 then
call UnitRemoveAbility(gt_unit,book)
call UnitRemoveAbility(gt_unit,abilityid)
call UnitRemoveAbility(gt_unit,buffability)
call GroupRemoveUnit(zhuzhu_aura_group,gt_unit)
call FlushKey(gt_unit,I2S(abilityid))
else
call AddInt(gt_unit,I2S(abilityid),-1)
endif
call GroupRemoveUnit(gt_group,gt_unit)
endloop
call DestroyGroup(gt_group)
endfunction
function zhuzhu_aura_conditions takes nothing returns boolean
local unit zhuzhu_aura_hero
local timer zhuzhu_aura_timer
local group zhuzhu_aura_group
local integer aura
set aura=GetTriggerInt("aura_aura")
set zhuzhu_aura_hero=GetTriggerUnit()
//第一次学习技能时有效
if GetLearnedSkill() == aura and GetUnitAbilityLevel(zhuzhu_aura_hero,aura)==1 then
set zhuzhu_aura_hero=GetTriggerUnit()
set zhuzhu_aura_timer=CreateTimer()
call TimerStart(zhuzhu_aura_timer,1,true,function add_timed_ability)
set zhuzhu_aura_group=CreateGroup()
//读取并设置数据: 英雄,光环影响单位组,魔法书,真正技能,buff范围,友敌
call SetUnit(zhuzhu_aura_timer,"aura_hero",zhuzhu_aura_hero)
call SetGroup(zhuzhu_aura_timer,"aura_group",zhuzhu_aura_group)
call SetInt(zhuzhu_aura_timer,"aura_book",GetTriggerInt("aura_book"))
call SetInt(zhuzhu_aura_timer,"aura_abilityid",GetTriggerInt("aura_abilityid"))
call SetInt(zhuzhu_aura_timer,"aura_buffability",GetTriggerInt("buffability"))
call SetReal(zhuzhu_aura_timer,"aura_r",GetTriggerReal("aura_r"))
call SetBool(zhuzhu_aura_timer,"aura_allay",GetTriggerBool("aura_allay"))
//标记这个英雄
call SetTimer(zhuzhu_aura_hero,I2S(GetTriggerInt("aura_abilityid")),zhuzhu_aura_timer)
else
set zhuzhu_aura_timer=GetTimer(zhuzhu_aura_hero,I2S(GetTriggerInt("aura_abilityid")))
endif
//光环等级升级
if GetLearnedSkill() == aura then
call SetInt(zhuzhu_aura_timer,"aura_level",GetUnitAbilityLevel(zhuzhu_aura_hero,aura))
endif
return true
endfunction
function zhuzhu_aura_init takes integer aura,integer book,integer abilityid,integer buffability,real r,boolean allay returns nothing
local trigger zhuzhu_aura
local integer index
//禁止这个魔法书
set index=0
loop
exitwhen index>15
call SetPlayerAbilityAvailable(Player(index),book,false)
set index=index+1
endloop
set zhuzhu_aura= CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( zhuzhu_aura, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( zhuzhu_aura, Condition(function zhuzhu_aura_conditions ))
//存储数据: 光环技能,魔法书,真正技能,范围,友敌
call SetInt(zhuzhu_aura,"aura_aura",aura)
call SetInt(zhuzhu_aura,"aura_book",book)
call SetInt(zhuzhu_aura,"aura_abilityid",abilityid)
call SetInt(zhuzhu_aura,"aura_buffability",buffability)
call SetReal(zhuzhu_aura,"aura_r",r)
call SetBool(zhuzhu_aura,"aura_allay",allay)
endfunction
function InitAura takes integer abilityid,integer book,integer buffability,real r,boolean allay returns nothing
call zhuzhu_aura_init(abilityid,book,abilityid,buffability,r,allay)
endfunction
[/codes] |
|