找回密码
 点一下
查看: 2704|回复: 3

较简单的JASS之一(技能)——海浪侵袭

[复制链接]
发表于 2008-9-13 13:18:08 | 显示全部楼层 |阅读模式
呵呵…………
这个技能包含了ReturnBug+GameCache+Timer有兴趣进阶的同学可以耐下心来看哦~~

首先是基本函数:
[codes=jass]
function GetGC takes nothing returns gamecache
if udg_GC == null then
call FlushGameCache(InitGameCache("XLGC.w3v"))
set udg_GC = InitGameCache("XLGC.w3v")
return udg_GC
endif
return udg_GC
endfunction
//获得GameCache

function H2I takes handle h returns integer
return h
return 0
endfunction
//这就是大名鼎鼎的H2I

function SetTimerUnit takes timer ti ,unit u ,integer number returns nothing
call StoreInteger(GetGC(),I2S(H2I(ti)),"Unit"+I2S(number),H2I(u))
endfunction
//设置绑定在timer上的unit

function GetTimerUnit takes timer ti ,integer number returns unit
return GetStoredInteger(GetGC(),I2S(H2I(ti)),"Unit"+I2S(number))
return null                 //这个函数和I2U的道理是一样的
endfunction
//获得绑定在timer上的unit
[/codes]
这几个大家都能看得出来吧?

接下来,看:
[codes=jass]
function Water_GetMaJiaId takes nothing returns integer
return 'h000'        //马甲ID
endfunction

function Water_GetMaJiaAbilityId takes unit u,integer ability_level returns integer
return 'A000'        //马甲技能ID
endfunction

function Water_GetMaJiaAbilityOrder takes unit u,integer ability_level returns string
return "carrionswarm"  //马甲技能命令字符串
endfunction

function Water_GetWaterNumber takes unit u,integer ability_level returns integer
return 20             //共几次水波
endfunction

function Water_GetTimeVal takes unit u,integer ability_level returns real
return 0.33           //共几秒发射一次水波
endfunction[/codes]
这些都是设置数据的函数,大家可以忽略~~

最后三个函数:
[codes=jass]function Water_MaJia_Spell takes unit MaJia, unit u, integer ability_level returns nothing
call UnitAddAbility(MaJia,Water_GetMaJiaAbilityId(u,ability_level))
call ShowUnit(MaJia,false)
call SetUnitPathing(MaJia,false)
call SetUnitFacing(MaJia,GetUnitFacing(u))
call SetUnitX(MaJia,GetUnitX(u))
call SetUnitY(MaJia,GetUnitY(u))
call IssueTargetOrder(MaJia,Water_GetMaJiaAbilityOrder(u,ability_level),MaJia)
call UnitApplyTimedLife(MaJia,'BHwe',2.0)
endfunction

function Water_TimerAction takes nothing returns nothing
local timer ti = GetExpiredTimer()
local unit u = GetTimerUnit(ti,0)
local integer level = GetStoredInteger(GetGC(),I2S(H2I(ti)),"Level")
local unit MaJia = CreateUnit(GetOwningPlayer(u),Water_GetMaJiaId(),GetUnitX(u),GetUnitY(u),GetUnitFacing(u))
local integer num = GetStoredInteger(GetGC(),I2S(H2I(ti)),"Number")
set num = num + 1
if num > Water_GetWaterNumber(u,level)-1 then
call RemoveUnit(MaJia)
call FlushStoredMission(GetGC(),I2S(H2I(ti)))
call DestroyTimer(ti)
set ti = null
set u = null
set MaJia = null
else
call StoreInteger(GetGC(),I2S(H2I(ti)),"Number",num)
call Water_MaJia_Spell(MaJia,u,level)
endif
set ti = null
set u = null
set MaJia = null
endfunction

function Water_Spell takes unit u,integer ability_level returns nothing
local timer ti = CreateTimer()
local unit MaJia = CreateUnit(GetOwningPlayer(u),Water_GetMaJiaId(),GetUnitX(u),GetUnitY(u),GetUnitFacing(u))
call Water_MaJia_Spell(MaJia,u,ability_level)
call SetTimerUnit(ti,u,0)
call StoreInteger(GetGC(),I2S(H2I(ti)),"Level",ability_level)
call TimerStart(ti,Water_GetTimeVal(u,ability_level),true,function Water_TimerAction )
set ti = null
set MaJia = null
endfunction[/codes]
Water_MaJia_Spell 就是获得让马甲释放技能的函数。
应该能看出来吧~~

然后看Water_Spell这个函数(待会再看Water_TimerAction),
就是创建一个马甲,然后释放技能而已。
再创建一个Timer,并给Timer绑定数据(英雄和英雄技能等级)
最后命令Timer开始计时,时间到时运行Water_TimerAction

那么最后看Water_TimerAction:
local部分获得被绑定的数据(英雄和英雄技能等级),并创建一个马甲。
最重要的是一个num,这是记录Timer到时次数的integer
然后将num加1
是一个 if  判断
如果 num(即Timer到时次数) 大于 指定的海波数
那么,清除所有的数据和马甲
如果不是
就让马甲释放技能。
就完了。
(被自己忍无可忍的和谐掉了)

海浪侵袭.w3x

27 KB, 下载次数: 176

评分

参与人数 1威望 +21 收起 理由
Сynthia + 21 8错8错~不过没耐心看了~

查看全部评分

发表于 2008-9-13 13:21:11 | 显示全部楼层
为什么先发二和三 再发一?
回复

使用道具 举报

发表于 2008-9-13 13:41:50 | 显示全部楼层
英雄死了
还在释放海浪
回复

使用道具 举报

发表于 2008-9-14 19:35:50 | 显示全部楼层
.......看不懂..........
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-7 05:52 , Processed in 0.163024 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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