偶久网

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索

网站魔兽热门地图

查看: 3442|回复: 5

通用英雄复活模板-jass版

  [复制链接]
ou99孽缘 title=
发表于 2011-1-25 17:49:42
写了个通用的复活演示:调用方便,只用一个函数即可,推荐新手使用
1:复活后自动镜头移动复活点,自动选择复活英雄
2:可随意设置和等级相关的复活时间
3:可设置复活后的生命和魔法的百分比4:复活计时窗口显示

函数:
call HeroRevive ( 复活英雄单位,  复活基础时间,复活等级时间等级基数,复活x坐标,  复活y坐标, 是否显示复活效果,复活生命百分比,复活魔法百分比)
call HeroReviveLoc ( 复活英雄单位,  复活基础时间,复活等级时间等级基数,复活点, 是否显示复活效果,复活生命百分比,复活魔法百分比)

复活时间=复活基础时间+英雄等级*复活等级时间等级基数
如果 复活等级时间等级基数 为0 则复活时间于等级无关

复活生命百分比,设置1.0为满生命,复活魔法百分比,设置1.0为满魔法


列1:这个列子是每当玩家英雄死亡就复活
事件:任意单位死亡
条件:死亡单位 是英雄 等于true
         死亡单位的玩家控制者 不等于 电脑
动作:
call HeroRevive(GetTriggerUnit(), 15,0,GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), false,1,1)
//设置英雄15秒钟后在死亡位置复活,复活后生命值和魔法均为最满值



列2:针对某些英雄的复活
事件:任意单位死亡
条件:死亡单位的类型 等于 大法师 或者 死亡单位的类型 等于山丘之王 或者 死亡单位的类型 等于 圣骑士
         或者死亡单位的类型等于 血魔法师 。。。。。。。      
动作:
call HeroReviveLoc(GetTriggerUnit(), 10,1,udg_dian, false,0.5,0.5)
//设置英雄(10+英雄等级)秒钟后在点dian处复活,复活后生命值和魔法为50%

Shingo Jass Highlighter 0.41 //作者:茄子
//------------------------V 1.00-----------------------------------

//说明:

//call HeroRevive ( hero,  time, base, x,  y,  eff,life, mana)
//hero 为需要复活的英雄,time为复活时间,base 为与复活等级相关的基数(设置为0,则复活时间和等级无关),x,y为复活的坐标,eff为boolean值,如果如true,者显示复活效果
//life为复活的生命百分比,1.0为满生命值
//mana为复活的魔法百分比,1.0为满魔法值
//
library HeroRevival

globals

    private constant real PANCAM        = 0.025
    private timer TIMEHR=CreateTimer()
    private integer TOTAL=0
    private integer array STR
    private group NOSTACK   = CreateGroup()

endglobals
    //这里设置需要复活的时间与英雄等级有关的时间,可根需求修改
    private function GetAdjustedTime takes real time,real base, integer herolvl returns real
        return time + base * herolvl
    endfunction
    private function FilterHero takes unit u returns boolean
        return IsUnitType(u, UNIT_TYPE_HERO) and GetWidgetLife(u) < 0.405 and IsUnitType(u, UNIT_TYPE_DEAD)
    endfunction

    struct Revival
        unit                hero
        real                x
        real                y
        boolean             eff
        timerdialog         timewindow
        real                settime
        real                count=0.
        timer               CRTIME
        real                life
        real                mana
        static      Revival data

    static method Loop takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen i == TOTAL
            set data = STR
            if data.count>=data.settime then
                call ReviveHero(data.hero, data.x, data.y, data.eff)    //revive hero
                call SetUnitState(data.hero,UNIT_STATE_MANA,GetUnitState(data.hero,UNIT_STATE_MAX_MANA) * data.mana )
                call SetUnitState(data.hero,UNIT_STATE_LIFE,GetUnitState(data.hero,UNIT_STATE_MAX_LIFE) * data.life )
                call GroupRemoveUnit(NOSTACK, data.hero)
                if GetLocalPlayer() == GetOwningPlayer(data.hero) then
                    call PanCameraToTimed(data.x, data.y, PANCAM)
                    call ClearSelection()
                    call SelectUnit(data.hero, true)
                endif
                call  DestroyTimer(data.CRTIME)
                call  DestroyTimerDialog(data.timewindow)
                set TOTAL = TOTAL - 1
                set STR = STR[TOTAL]
                set i = i - 1
                call data.destroy()
            else
                if data.count==0. then
                    set data.CRTIME=CreateTimer()
                    set data.timewindow=CreateTimerDialog(data.CRTIME)
                    call TimerStart(data.CRTIME, data.settime, false, null)
                    call TimerDialogSetTitle(data.timewindow,GetUnitName(data.hero)+" 复活计时 ")
                    call TimerDialogDisplay(data.timewindow,true)
                endif
                set data.count=data.count+PANCAM
             endif
             set i = i + 1
        endloop
        if TOTAL == 0 then
            call PauseTimer(TIMEHR)
        endif
    endmethod

    endstruct

    function HeroRevive takes unit hero, real time,real base, real x, real y, boolean eff, real life, real mana returns nothing
        local Revival dat

        if FilterHero(hero) and not IsUnitInGroup(hero, NOSTACK) then
            set dat = Revival.create()
            set dat.hero = hero
            set dat.x = x
            set dat.y = y
            set dat.eff = eff
            set dat.life=life
            set dat.mana=mana

            set dat.settime=GetAdjustedTime(time, base,GetHeroLevel(hero))
            call GroupAddUnit(NOSTACK, hero)
            set STR[TOTAL] = dat
            set TOTAL = TOTAL + 1
            if TOTAL == 1 then
                call TimerStart(TIMEHR, PANCAM, true, function Revival.Loop)
            endif
        debug else
            debug call BJDebugMsg("错误,英雄还存活或者无单位,请检测触发")
        endif
    endfunction

    function HeroReviveLoc takes unit hero, real time,real base, location loc, boolean eff,real life,real mana returns nothing
        call HeroRevive(hero, time, base,GetLocationX(loc), GetLocationY(loc), eff,life,mana)
    endfunction

endlibrary

ou99孽缘 title=
 楼主| 发表于 2011-1-25 17:50:10
{:6_325:}
a937275781
发表于 2011-2-13 20:02:33
看了很晕{:6_324:}
快速回复 返回顶部 返回列表