找回密码
 点一下
查看: 1461|回复: 8

求dota技能演示

[复制链接]
发表于 2009-1-4 15:52:12 | 显示全部楼层 |阅读模式
求dota地扑师忽悠技能演示

其实主要不懂的是,在支持多人的jass写法中如何对单位组进行操作

寻常的T写法选取单位组中单位做动作,在jass中应该如何写

这个一直是我比较模糊的地方
发表于 2009-1-4 16:02:45 | 显示全部楼层
选取单位组单位做动作是ForGroup(),参数group,function code
动作就是function code对应的函数
回复

使用道具 举报

发表于 2009-1-4 16:03:33 | 显示全部楼层
dota,,那个不知道,没玩,,
回复

使用道具 举报

发表于 2009-1-4 16:06:16 | 显示全部楼层
多人用数组变量,然后用玩家索引,绑定到每个玩家
回复

使用道具 举报

发表于 2009-1-4 16:31:08 | 显示全部楼层
嗯,最基本的写法:
[jass]
function grouptest3 takes nothing returns nothing
call KillUnit(GetEnumUnit())
endfunction

function grouptest2 takes nothing returns boolean
return IsUnitAilveBJ(GetFilterUnit())
endfunction

function grouptest1 takes nothing returns nothing
local group g = CreateGroup()
call GroupEnumUnitsInRange(g,0,0,500.,Filter(function grouptest2))
call ForGroup(g,function grouptest3)
call DestroyGroup(g)
set g = null
[/jass]

当然,上面的写法第一不能传递引数,第二效率低。(因为用了ForGroup) 但是这基本就是ForGroupBJ()的效果。

如果希望效率高一点,那么可以直接把动作写到grouptest2里,即GroupEnumUnitsInRange时便运行动作,这方面你可以看看老狼写过的一篇文章:http://www.islga.org/bbs/read.php?tid=22202

还有,要是嫌引数传来传去很麻烦,那么可以试试这种方法:http://www.islga.org/bbs/read.php?tid=22273&fpage=2(别说我做广告啊.......)

随便说了几点,也不知道是不是lz想问的......
回复

使用道具 举报

 楼主| 发表于 2009-1-4 17:32:12 | 显示全部楼层
T选取单位组的时候有一个条件判断

如果用firseofgroup这样的写法的话

是否是先条件为空,将范围内所有单位全部选取进去,然后一一判断做动作?

这样的话,其实效率也差不多吧

T选取的时候应该也给每一个单位做了判断吧

何来效率变低的说
回复

使用道具 举报

发表于 2009-1-4 17:33:58 | 显示全部楼层
我的意思是说跟方法二比,LZ理解错了。

而且我的那个方法其实在某种程度上不是比ForGroup的效率还要低么......那个方法只是不用找一大堆全局变量把要的东西传过去,这样也少了像单位接受伤害导致全局变量改变的问题。
回复

使用道具 举报

 楼主| 发表于 2009-1-4 18:07:49 | 显示全部楼层


不懂~

某种程度是什么意思呀?

来个演示吧

=。= 我习惯看演示 对于理论比较头大

谢谢了
回复

使用道具 举报

发表于 2009-1-4 18:42:53 | 显示全部楼层
额........你要这么说我只好再做广告了(没办法,不知道其他什么地方有.....)

刚刚发的链模拟:
http://www.islga.org/bbs/read.php?tid=23243

一个就是 Test Trigger 2 下的:
[jass]
function Goushou_R_G_C takes nothing returns boolean
    return ((IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit()))) and (GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) > 0))
endfunction

function Goushou_Timer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local group g
    local group tempg
    local unit u = I2U(GetStoredInteger(udg_GC,I2S(H2I(t)),"caster"))
    local unit ua
    local integer i = GetStoredInteger(udg_GC,I2S(H2I(t)),"counter") - 1
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real angle
    call StoreInteger(udg_GC,I2S(H2I(t)),"counter",i)
    if i != 0 then
        set g = I2G(GetStoredInteger(udg_GC,I2S(H2I(t)),"group"))
        set tempg = CreateGroup()
        loop
            set ua = FirstOfGroup(g)
            exitwhen ua == null
                set angle = Atan2(GetUnitY(ua)-y,GetUnitX(ua)-x)
                if i - (i / 4) * 4 == 0 then
                    call DestroyEffect(AddSpecialEffect("Objects\\\\Spawnmodels\\\\Undead\\\\ImpaleTargetDust\\\\ImpaleTargetDust.mdl",GetUnitX(ua),GetUnitY(ua)))
                endif
                call SetUnitFacing(ua,GetUnitFacing(ua)+120)
                call SetUnitX(ua,GetUnitX(ua)+15*Cos(angle))
                call SetUnitY(ua,GetUnitY(ua)+15*Sin(angle))
                call GroupRemoveUnit(g,ua)
                call GroupAddUnit(tempg,ua)
        endloop
        loop
            set ua = FirstOfGroup(tempg)
            exitwhen ua == null
                call GroupRemoveUnit(tempg,ua)
                call GroupAddUnit(g,ua)
        endloop
        call DestroyGroup(tempg)
        set tempg = null
    else
        call PauseTimer(t)
        call DestroyGroup(g)
        call FlushStoredMission(udg_GC,I2S(H2I(t)))
        call DestroyTimer(t)
    endif
    set u = null
    set t = null
    set g = null
endfunction

function Trig_AEfk_Conditions takes nothing returns boolean
    local timer t
    local group g
    if GetSpellAbilityId() == 'A004' then
        set t = CreateTimer()
        set g = CreateGroup()
        call GroupEnumUnitsInRange(g,GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),500,Condition(function Goushou_R_G_C))
        call StoreInteger(udg_GC,I2S(H2I(t)),"caster",H2I(GetTriggerUnit()))
        call StoreInteger(udg_GC,I2S(H2I(t)),"group",H2I(g))
        call StoreInteger(udg_GC,I2S(H2I(t)),"counter",15)
        call TimerStart(t,.04,true,function Goushou_Timer)
        set t = null
        set g = null
    endif
    return false
endfunction
[/jass]

注意看跟Group有关的语句。此为方法三。如果是方法二的话]就要在[jass]call GroupEnumUnitsInRange(g,GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),500,Condition(function Goushou_R_G_C))[/jass]之前搞个全局变量把施法单位(或是说从哪一点为击退中心)的坐标记录(记得当初我用的是bj_meleeNearestMineToLoc还是其他什么的,总而言之是个看起来就满危险的全局bj变量.....)。然后把[jass]                call SetUnitFacing(ua,GetUnitFacing(ua)+120)
                call SetUnitX(ua,GetUnitX(ua)+15*Cos(angle))
                call SetUnitY(ua,GetUnitY(ua)+15*Sin(angle))[/jass]之类的东西写到function Goushou_R_G_C下

额,由于例子没举好,看下面一个.......

[jass]
function Goushou_R_G_C takes nothing returns boolean
    return ((IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit()))) and (GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) > 0))
endfunction

function Goushou_R_G takes nothing returns nothing
    local real LocX = GetUnitX(GetEnumUnit())
    local real LocY = GetUnitY(GetEnumUnit())
    local real angle = Atan2(GetUnitY(bj_lastCreatedUnit)-LocY,GetUnitX(bj_lastCreatedUnit)-LocX)
    set LocX = LocX + 70 * Cos(angle)
    set LocY = LocY + 70 * Sin(angle)
    if (LocX > GetRectMinX(bj_mapInitialPlayableArea)) and (LocX < GetRectMaxX(bj_mapInitialPlayableArea)) and (LocY > GetRectMinY(bj_mapInitialPlayableArea)) and (LocY < GetRectMaxY(bj_mapInitialPlayableArea)) then
        call SetUnitX(GetEnumUnit(),LocX)
        call SetUnitY(GetEnumUnit(),LocY)
        call DestroyEffect(AddSpecialEffect("Objects\\\\Spawnmodels\\\\Undead\\\\ImpaleTargetDust\\\\ImpaleTargetDust.mdl",LocX,LocY))
    endif
endfunction

function Goushou_Timer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local group g = I2G(GetStoredInteger(udg_GC,I2S(H2I(t)),"group"))
    local unit u = I2U(GetStoredInteger(udg_GC,I2S(H2I(t)),"caster"))
    local integer i = GetStoredInteger(udg_GC,I2S(H2I(t)),"counter") - 1
    call StoreInteger(udg_GC,I2S(H2I(t)),"counter",i)
    if i != 0 then
        set bj_lastCreatedUnit = u
        call ForGroup(g,function Goushou_R_G)
    else
        call PauseTimer(t)
        call DestroyGroup(g)
        call FlushStoredMission(udg_GC,I2S(H2I(t)))
        call DestroyTimer(t)
    endif
    set u = null
    set t = null
    set g = null
endfunction

function Trig_AEfk_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local group g = CreateGroup()
    call GroupEnumUnitsInRange(g,GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),500,Condition(function Goushou_R_G_C))
    call StoreInteger(udg_GC,I2S(H2I(t)),"caster",H2I(GetTriggerUnit()))
    call StoreInteger(udg_GC,I2S(H2I(t)),"group",H2I(g))
    call StoreInteger(udg_GC,I2S(H2I(t)),"counter",10)
    call TimerStart(t,.05,true,function Goushou_Timer)
    set t = null
    set g = null
endfunction
[/jass]

在ForGroup之前用到了bj_lastCreatedUnit。

代码的效率问题就别吐我槽了,因为是以前写的........
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-7-15 20:25 , Processed in 0.036553 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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