魔兽首页最新地图防守地图对抗地图角色剧情TD塔类图标准战役ORPG地图其它地图
魔兽论坛攻略秘籍补丁工具RPG 录像制图教学制图资源魔兽战队新图试玩通魔作坊

您的位置:魔兽争霸U9网 >> 制图教学

通魔之路(WE主讨论区):[JASS]完美的刷怪系统

作者:lars    文章来源:U9论坛    点击数:    更新时间:2006-8-30 18:05:05
只需要在地图初始化的时候call InitCreep(),然后在Unit Die事件中call CreepDie(GetDyingUnit())就行了,注意要加一个
GameCache的变量CC, 这里设定的90s后自动复活,你可以自己修改.
特点:
1. 刷怪功能完美,,刷的新怪和原来的怪物初始位置相同,而且我这里设定了有50%的几率会刷出一个同等级但
是随机类型的怪物出来。可以自行取舍。召唤的出来的怪物不会被误刷。
2. 只需要利用地图的GameCache,不需要变量。
3. 我这里设定了当怪物原来所在的位置有建筑物时则不会复活,一直等到没有建筑物了再复活。这个设定是为了
避免已经清理矿区造好基地了,怪物还在不停的刷。可以自行取舍。
4. 里面附带了掉宝系统。
//Creep Die,只需要调用CreepDie()函数和InitCreep()函数
function H2HI takes handle h returns integer
    return h
    return 0
endfunction

function NearToBuildingFilter0 takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and GetPlayerId(GetOwningPlayer(GetFilterUnit()))<=11
endfunction

function NearToBuilding takes real X, real Y returns boolean
    local location loc=Location(X,Y)
    local group g=GetUnitsInRangeOfLocMatching(800, loc, Condition(function NearToBuildingFilter0))
    local boolean yn=( FirstOfGroup(g)!=null )
    call RemoveLocation(loc)
    call DestroyGroup(g)
    return yn
endfunction

function CreepRevive takes nothing returns nothing
    local timer tm= GetExpiredTimer()
    local string tmMis="CreepTimer"+I2S(H2HI(tm))
    local string creepMis
    local integer TypeId=GetStoredInteger(udg_CC,tmMis,"TypeId")
    local real X=GetStoredReal(udg_CC,tmMis,"X")
    local real Y=GetStoredReal(udg_CC,tmMis,"Y")
    local real Facing=GetStoredReal(udg_CC,tmMis,"Facing")
    local unit u
    if NearToBuilding(X,Y) then
        call TimerStart(tm,60,false,function CreepRevive)
        return
    endif

    call FlushStoredMission(udg_CC,tmMis)
    call DestroyTimer(tm)
    set u=CreateUnit(Player(12),TypeId,X,Y,Facing)
    call SetUnitAcquireRange( u, 200 )
    set creepMis="Creep"+I2S(H2HI(u))
    call StoreInteger(udg_CC,creepMis,"TypeId",TypeId)
    call StoreReal(udg_CC,creepMis,"X",X)
    call StoreReal(udg_CC,creepMis,"Y",Y)
    call StoreReal(udg_CC,creepMis,"Facing",Facing)
endfunction

function CreepDie takes unit u returns nothing
    local integer itemId=0
    local string mis="Creep"+I2S(H2HI(u))
    local timer tm=CreateTimer()
    local string tmMis="CreepTimer"+I2S(H2HI(tm))
    local integer TypeId=0
    //drop item
    if GetRandomInt(1,100)<=20 then
        loop
            exitwhen itemId!=0
            set itemId=ChooseRandomItemEx(ConvertItemType(GetRandomInt(0,4)),GetUnitLevel(u)*GetRandomInt(7,10)/10)
        endloop
        call CreateItem(itemId,GetUnitX(u),GetUnitY(u))
    endif
    //revive creep
    set TypeId=GetStoredInteger(udg_CC,mis,"TypeId")
    if TypeId==0 then
        //unknown creep, no revive
        return
    endif
    if GetRandomInt(1,2)<=1 then
        set TypeId=ChooseRandomCreep(GetUnitLevel(u))
    endif
    call StoreInteger(udg_CC,tmMis,"TypeId",TypeId)
    call StoreReal(udg_CC,tmMis,"X",GetStoredReal(udg_CC,mis,"X"))
    call StoreReal(udg_CC,tmMis,"Y",GetStoredReal(udg_CC,mis,"Y"))
    call StoreReal(udg_CC,tmMis,"Facing",GetStoredReal(udg_CC,mis,"Facing"))
    call FlushStoredMission(udg_CC,mis)
    call TimerStart(tm,90,false,function CreepRevive)
endfunction

//Init Creep
function InitCreepEnum takes nothing returns nothing
    local unit u=GetEnumUnit()
    local string mis
    if IsUnitType(u,UNIT_TYPE_STRUCTURE)==false then
        set mis="Creep"+I2S(H2HI(u))
        call StoreInteger(udg_CC,mis,"TypeId",GetUnitTypeId(u))
        call StoreReal(udg_CC,mis,"X",GetUnitX(u))
        call StoreReal(udg_CC,mis,"Y",GetUnitY(u))        
        call StoreReal(udg_CC,mis,"Facing",GetUnitFacing(u))
    endif
endfunction

function InitCreep takes nothing returns nothing
    local group g=CreateGroup()
    call GroupEnumUnitsOfPlayer(g,Player(12),null)
    call ForGroup(g, function InitCreepEnum )
    call DestroyGroup(g)
endfunction

[ 本帖最后由 lars 于 2006-3-14 12:24 编辑 ]
责任编辑:瞳瞳
进入论坛参与针对本文章的讨论
文中部分附件请进入论坛下载
本文章地址:
  • 上一篇:通魔之路(WE主讨论区):关于光环Bug的研究
  • 下一篇:
  • 相关文章

    进入论坛参与针对本文章的讨论用户评论

    地图 攻略
    热门搜索: 仙之侠道 真三国无双 Dota Allstar

    地图专区导航

    热门地图攻略

    热门地图周排行

    最新推荐地图

    地图下载总排行

    关于我们  -  联系我们  -  广告优势  -  广告服务
    建议意见:玩家点击留言  商务合作:客户点击留言
    西安优久数码科技有限公司 版权所有 陕ICP证08000654号