找回密码
 点一下
查看: 1579|回复: 6

一个随机刷怪系统的问题

[复制链接]
发表于 2010-3-25 10:29:43 | 显示全部楼层 |阅读模式
刷出单位出现的问题是总是少刷一个,造成后面的统计剩余数量也跟着出问题.
求代码有问题的地方.
 楼主| 发表于 2010-3-25 10:35:49 | 显示全部楼层
//创建
function Spawn takes nothing returns nothing
local integer i = 1
local trigger t
local real x
local real y
set t = CreateTrigger()
call TriggerAddAction(t,function ParasiteSporeDeath)
set i=1
loop
exitwhen i>24
set x = GetRandomReal(GetRectMinX(udg_PlayerSpawnBoundary),GetRectMaxX(udg_PlayerSpawnBoundary))
set y = GetRandomReal(GetRectMinY(udg_PlayerSpawnBoundary),GetRectMaxY(udg_PlayerSpawnBoundary))
if IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) and not(IsTerrainPathable(x,y,PATHING_TYPE_AMPHIBIOUSPATHING)) then
call DestroyEffect(AddSpecialEffect( "Objects\\\\Spawnmodels\\\\Naga\\\\NagaDeath\\\\NagaDeath.mdl", x, y ))
else
call DestroyEffect(AddSpecialEffect("Objects\\\\Spawnmodels\\\\Undead\\\\ImpaleTargetDust\\\\ImpaleTargetDust.mdl",x,y))
endif
set udg_ParasiteSpore = CreateUnit(Player(13),'e00C',x,y,0.0)
call TriggerRegisterUnitEvent(t,udg_ParasiteSpore,EVENT_UNIT_DEATH)
set udg_Spores=udg_Spores+1
call TriggerSleepAction(0.)
set i=i+1
endloop
set t = null
endfunction

//死亡统计
function ParasiteSporeDeath takes nothing returns nothing
    local integer i = 1
    local unit u = GetTriggerUnit()
    loop
        exitwhen i>24
        if u==udg_ParasiteSpore then
            set udg_ParasiteSpore = null
            exitwhen 1==1
        endif
        set i=i+1
    endloop
    set udg_Spores=udg_Spores-1
    if udg_Spores<=0 then
        //call DestroyTrigger(GetTriggeringTrigger())
        if udg_Mode==1 then
            call ALICE2Text(10.0, "所有xxx被消灭." )
            set i = 1
        endif
    else
        if udg_Spores==1 then
            call ALICEText(10.0, I2S(udg_Spores) + " 个剩余." )
        else
            call ALICEText(10.0, I2S(udg_Spores) + " 个剩余." )
        endif
    endif
    if udg_Spores==4 then
        set i=1
    endif
    set u = null
endfunction
回复

使用道具 举报

发表于 2010-3-25 12:54:27 | 显示全部楼层
看到这繁琐的代码,悲剧帝无奈了
回复

使用道具 举报

发表于 2010-3-25 14:44:36 | 显示全部楼层
[jass]
local integer i = 1
exitwhen i>24
set udg_Spores=udg_Spores+1
set i=i+1


local integer i = 1
exitwhen i>24
set i=i+1
set udg_Spores=udg_Spores-1
[/jass]
应该把exitwhen i>24放在 udg_Spores+1-1下面或者i=0试试...................
如果udg_Spores默认是1的话就不是这个问题.....................
回复

使用道具 举报

 楼主| 发表于 2010-3-28 18:05:51 | 显示全部楼层
代码貌似是没问题的..反着写反而会出异常..
顺便想了下其它的解决方法.但是呢老是提示错误..
也就是手动解决.

function LastSporesActions takes nothing returns nothing
    local location l
    local trigger t
    local real x
    local real y
    local real dx
    local real dy
    local integer i=1
    set t = CreateTrigger()
    set l = GetRandomLocInRect(bj_mapInitialPlayableArea)
    loop
        set x = GetLocationX(l)
        set y = GetLocationY(l)
        set dx = x-GetUnitX(udg_Residence41)
        set dy = y-GetUnitY(udg_Residence41)
        exitwhen dx*dx+dy*dy>25000000.0
        call RemoveLocation(l)
        set l = GetRandomLocInRect(bj_mapInitialPlayableArea)
    endloop
    set udg_ParasiteSpore = CreateUnit(Player(13),'e00C',l,0.0)
    call RemoveLocation(l)
    call TriggerRegisterUnitEvent(t,udg_ParasiteSpore,EVENT_UNIT_DEATH)
endfunction

//===========================================================================
function LastSpores takes nothing returns nothing
    set LastSpores = CreateTrigger()
    call TriggerRegisterPlayerChatEvent(LastSpores,Player(0),"ls",true)
    call TriggerAddAction(LastSpores, function LastSporesActions)
endfunction

错误总是提示是Not enough arguments given to function: CreateUnits
回复

使用道具 举报

发表于 2010-3-30 14:11:06 | 显示全部楼层
是缺参数
回复

使用道具 举报

发表于 2010-3-30 17:42:33 | 显示全部楼层
[jass]
local location l
set l = GetRandomLocInRect(bj_mapInitialPlayableArea)


set udg_ParasiteSpore = CreateUnit(Player(13),'e00C',l,0.0)
native    CreateUnit    takes player id, integer unitid, real x, real y, real face returns unit
[/jass]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-19 14:07 , Processed in 0.380459 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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