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

麻烦看看这个刷怪函数有没有泄漏,刷怪的时候总是很卡(10更新代码注释)

[复制链接]
发表于 2009-3-9 11:21:24 | 显示全部楼层 |阅读模式
困扰好多天了。。。左看右看似乎都没问题,难道不是这里的问题??

[codes=jass]
function U7V takes nothing returns nothing
local integer BEV=GL[194]
//BEV值是调节刷怪强度的,越大刷越多
local location LAV=GetRectCenter(MO)
//LAV是刷怪点
if(BEV<15)then
call CreateNUnitsAtLoc(2,'n00A',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(4,'n038',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(3.)
call CreateNUnitsAtLoc(2,'n01T',Player(11),LAV,bj_UNIT_FACING)
else
if(BEV<30)then
call CreateNUnitsAtLoc(2,'n01T',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(3,'n00A',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(2,'n00C',Player(11),LAV,bj_UNIT_FACING)
else
if(BEV<45)then
call CreateNUnitsAtLoc(1,'n00E',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(3,'n00F',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(3.)
call CreateNUnitsAtLoc(2,'n00G',Player(11),LAV,bj_UNIT_FACING)
else
if(BEV<60)then
call CreateNUnitsAtLoc(2,'n00E',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(2,'n00F',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(3.)
call CreateNUnitsAtLoc(3,'n00G',Player(11),LAV,bj_UNIT_FACING)
else
if(BEV<75)then
call CreateNUnitsAtLoc(3,'n00O',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(2,'n00F',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(3.)
call CreateNUnitsAtLoc(3,'n00G',Player(11),LAV,bj_UNIT_FACING)
else
if(BEV<90)then
call CreateNUnitsAtLoc(3,'n00O',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(1,'n039',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(3.)
call CreateNUnitsAtLoc(2,'n00R',Player(11),LAV,bj_UNIT_FACING)
else
if(BEV<'i')then
call CreateNUnitsAtLoc(2,'n00Q',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(1,'n039',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(3.)
call CreateNUnitsAtLoc(2,'n00P',Player(11),LAV,bj_UNIT_FACING)
else
if(BEV<'x')then
call CreateNUnitsAtLoc(3,'n00Q',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(2,'n039',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(3.)
call CreateNUnitsAtLoc(2,'n00P',Player(11),LAV,bj_UNIT_FACING)
else
call CreateNUnitsAtLoc(2,'n00S',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(2,'n00Q',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(2.)
call CreateNUnitsAtLoc(2,'n00R',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(3.)
call CreateNUnitsAtLoc(2,'n039',Player(11),LAV,bj_UNIT_FACING)
call TriggerSleepAction(3.)
call CreateNUnitsAtLoc(2,'n00P',Player(11),LAV,bj_UNIT_FACING)
endif
endif
endif
endif
endif
endif
endif
endif
call RemoveLocation(LAV)
set LAV=null
//清除点LAV,释放内存
endfunction

function U9V takes nothing returns nothing
local integer BEV=0
//BEV值控制刷怪强度
local integer tp=0
//在线人数
local integer p=0
//只是个开关变量
local integer WVV=0
local real U5V=.0
local location LAV=GetRectCenter(MO)
//LAV为刷怪点
loop
exitwhen(p>7)
if(GetPlayerController(Player(p))==MAP_CONTROL_USER)then
if(GetPlayerSlotState(Player(p))==PLAYER_SLOT_STATE_PLAYING)then
set BEV=GetHeroLevel(DL[p])
set tp=tp+1
endif
endif
set p=p+1
endloop
//上面的循环动作是根据在线玩家等级来调节刷怪的强度
set WVV=(BEV/ 4)+BEV
set GL[194]=(WVV/ tp)
call DestroyTimerDialog(KL[8])
//KL[8]是刷怪的计时器
call QuestMessageBJ(bj_FORCE_ALL_PLAYERS,1,"开始刷怪了!")
call PingMinimapLocForForce(bj_FORCE_ALL_PLAYERS,LAV,15.)
//下面这句只是友军防守的
call ForGroup(TL,function U8V)
//下面开始刷怪
call U7V()
call U7V()
call U7V()
set p=0
loop
exitwhen(p>3)
if(GetPlayerController(Player(p))==MAP_CONTROL_USER)then
if(GetPlayerSlotState(Player(p))==PLAYER_SLOT_STATE_PLAYING)then
set GL[194]=GetHeroLevel(DL[p])
call U7V()
endif
endif
set p=p+1
endloop
//这个是刷BOSS
set FM=CreateUnit(Player(11),'E003',7392.,14432.,bj_UNIT_FACING)
call SetHeroLevelBJ(FM,WVV,false)
set p=4
loop
exitwhen(p>7)
if(GetPlayerController(Player(p))==MAP_CONTROL_USER)then
if(GetPlayerSlotState(Player(p))==PLAYER_SLOT_STATE_PLAYING)then
set GL[194]=GetHeroLevel(DL[p])
call U7V()
endif
endif
set p=p+1
endloop
//销毁原来的刷怪计时器
call DestroyTimerDialog(KL[8])
//动态调节刷怪等待时间
set U5V=I2R(GetRandomInt(599+((BEV/ tp)*3),1200))
//开始新的刷怪计时
call TimerStart(NM,U5V,false,null)
set KL[8]=CreateTimerDialog(NM)
call TimerDialogSetTitle(KL[8],"下一次袭击")
call TimerDialogDisplay(KL[8],true)
call RemoveLocation(LAV)
set LAV=null
endfunction[/codes]
发表于 2009-3-9 16:28:48 | 显示全部楼层
把TriggerSleepAction除了试试(就是注释掉)。
看看。
回复

使用道具 举报

发表于 2009-3-9 20:16:54 | 显示全部楼层
这个暂停去掉了会更卡的吧。

您这段经过函数名优化后的代码,不是很容易看。
有很多变量和函数名,从字面上看不出原来的本意。
回复

使用道具 举报

发表于 2009-3-10 16:22:01 | 显示全部楼层
很简单,是个类似于3C刷兵的系统而已~~
但是确实在LZ的代码中找不到什么漏洞~~
试着不去调用U7V(),如果不卡则调整U7V这个函数。
如果卡,则是你的U9V函数出了问题。
回复

使用道具 举报

发表于 2009-3-11 12:28:24 | 显示全部楼层
至少LZ可以优化一点,既然玩家状态,玩家数等数据是经常使用的  可以再定义一个数Boolean组来记录状态 ,用不着每次都来判断

function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group
    call GroupClear(bj_lastCreatedGroup)
    loop
        set count = count - 1
        exitwhen count < 0
        call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
        call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
    endloop
    return bj_lastCreatedGroup
endfunction
这个也可以优化下,用CreateUnit()来做
TriggerSleepAction()也省略掉
LZ的U8V是什么函数?
U7V多次调用 可以将U7V和U9V合并一起  LZ的U7V的试用范围很窄 用不着单独模块化

还有,如果是第一次刷出某种单位,卡是正常的

bj_UNIT_FACING直接改为0
回复

使用道具 举报

发表于 2009-3-25 22:27:37 | 显示全部楼层
专业问题,不懂
回复

使用道具 举报

发表于 2009-3-26 18:20:22 | 显示全部楼层
他这个卡是因为第一次读取单位卡吧。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-21 23:07 , Processed in 0.061523 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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