发个图片弹幕函数~~
永恒的灌水帝吧
全部回复
仅看楼主
level 1
秋瀞葉 楼主
// -------------
//real MOVEIMAGETIMER_TIMEOUT=0.04
//! textmacro imageBulletsFunction takes NAME
globals
    image array imageBullet_$NAME$_images
    timer imageBullet_$NAME$_timer
    integer imageBullet_$NAME$_Max=0
    integer imageBullet_$NAME$_imageMax=0
    integer array imageBullet_$NAME$_id
    unit array imageBullet_$NAME$_spellunit
    real array imageBullet_$NAME$_x
    real array imageBullet_$NAME$_y
    real array imageBullet_$NAME$_z
    real array imageBullet_$NAME$_speed_x
    real array imageBullet_$NAME$_speed_y
    real array imageBullet_$NAME$_distance
    real array imageBullet_$NAME$_speed
    string array imageBullet_$NAME$_effpath
    string array imageBullet_$NAME$_targeteffpath
    real array imageBullet_$NAME$_collision
    real array imageBullet_$NAME$_range
    integer udg_$NAME$_Max = 0
    integer array udg_$NAME$_Flu
endglobals
function Create_$NAME$_Id takes nothing returns integer
    set udg_$NAME$_Max = udg_$NAME$_Max + 1
    debug call BJDebugMsg("$NAME$_Max_ID="+I2S(udg_$NAME$_Max))
    if udg_$NAME$_Max>8190 then
        call BJDebugMsg("|cffff0000 CreateImageId_$NAME$_error: cannot create id (>8190)|r")
        return 0
    endif
    if udg_$NAME$_Flu[udg_$NAME$_Max] == 0 then
        return udg_$NAME$_Max
    endif
    return udg_$NAME$_Flu[udg_$NAME$_Max]
endfunction
function Remove_$NAME$_Id takes integer tid returns nothing
    set udg_$NAME$_Flu[udg_$NAME$_Max] = tid
    set udg_$NAME$_Max = udg_$NAME$_Max - 1
    debug call BJDebugMsg("$NAME$_Max_ID="+I2S(udg_$NAME$_Max))
endfunction
function imageBullet_$NAME$_Preload takes nothing returns nothing
    local integer c=imageBullet_$NAME$_imageMax+IMAGE_BULLET_PRELOAD_AMOUNT
    debug call BJDebugMsg("Image_$NAME$ is preloading")
    if c>8190 then
        call BJDebugMsg("|cffff0000 Image_$NAME$_error: preload is failed|r")
        return
    endif
    loop
        set imageBullet_$NAME$_imageMax=imageBullet_$NAME$_imageMax+1
        exitwhen imageBullet_$NAME$_imageMax>c
        set imageBullet_$NAME$_images[imageBullet_$NAME$_imageMax]=CreateImage(IMAGE_BULLETS_paths[$NAME$],IMAGE_BULLETS_size[$NAME$],IMAGE_BULLETS_size[$NAME$],IMAGE_BULLETS_size[$NAME$],0,0,0,0,0,0,2)

2011年03月16日 04点03分 1
level 1
秋瀞葉 楼主
        call ShowImage(imageBullet_$NAME$_images[imageBullet_$NAME$_imageMax],false)
        call SetImageRenderAlways(imageBullet_$NAME$_images[imageBullet_$NAME$_imageMax],true)
    endloop
    set imageBullet_$NAME$_imageMax=imageBullet_$NAME$_imageMax-1
endfunction
function imageBullet_$NAME$_Delete takes integer id returns nothing
    call ShowImage(imageBullet_$NAME$_images[imageBullet_$NAME$_id[id]],false)
    call Remove_$NAME$_Id(imageBullet_$NAME$_id[id])
    set imageBullet_$NAME$_id[id]=imageBullet_$NAME$_id[imageBullet_$NAME$_Max]
    set imageBullet_$NAME$_Max=imageBullet_$NAME$_Max-1
endfunction
function imageBullet_$NAME$_New takes unit spellunit,real x,real y,real z,real angle,real speed,real distance,string effpath,real collision,real range,string targeteffpath returns nothing
    local integer id
    set imageBullet_$NAME$_Max=imageBullet_$NAME$_Max+1
    set id=imageBullet_$NAME$_Max
    if id>imageBullet_$NAME$_imageMax then
        call imageBullet_$NAME$_Preload()
    endif
    set imageBullet_$NAME$_id[imageBullet_$NAME$_Max]=Create_$NAME$_Id()
    set id=imageBullet_$NAME$_id[imageBullet_$NAME$_Max]
    set imageBullet_$NAME$_spellunit[id]=spellunit
    set imageBullet_$NAME$_x[id]=x
    set imageBullet_$NAME$_y[id]=y
    set imageBullet_$NAME$_z[id]=z
    set speed=speed*MOVEIMAGETIMER_TIMEOUT
    set imageBullet_$NAME$_speed_x[id]=speed*Cos(angle)
    set imageBullet_$NAME$_speed_y[id]=speed*Sin(angle)
    set imageBullet_$NAME$_distance[id]=distance
    set imageBullet_$NAME$_speed[id]=speed
    set imageBullet_$NAME$_effpath[id]=effpath
    set imageBullet_$NAME$_targeteffpath[id]=targeteffpath
    set imageBullet_$NAME$_collision[id]=collision
    set imageBullet_$NAME$_range[id]=range
    call ShowImage(imageBullet_$NAME$_images[id],true)
    call SetImagePosition(imageBullet_$NAME$_images[id],x,y,z)
endfunction
function imageBullet_$NAME$_TimerAction takes nothing returns nothing
    local integer id
    local integer i
    local group g
    local unit u
    local boolean b
    local player p
    set i=imageBullet_$NAME$_Max
    loop
        exitwhen i<=0
        set id=imageBullet_$NAME$_id[i]
        set b=false

2011年03月16日 04点03分 2
level 1
秋瀞葉 楼主
        set p=GetOwningPlayer(imageBullet_$NAME$_spellunit[id])
        if imageBullet_$NAME$_effpath[id]!=null then
            call DestroyEffect(AddSpecialEffect(imageBullet_$NAME$_effpath[id],imageBullet_$NAME$_x[id],imageBullet_$NAME$_y[id]))
        endif
        set imageBullet_$NAME$_x[id]=imageBullet_$NAME$_x[id]+imageBullet_$NAME$_speed_x[id]
        set imageBullet_$NAME$_y[id]=imageBullet_$NAME$_y[id]+imageBullet_$NAME$_speed_y[id]
        if (imageBullet_$NAME$_x[id]>MAP_MINX)and(imageBullet_$NAME$_y[id]>MAP_MINY)and(imageBullet_$NAME$_x[id]<MAP_MAXX)and(imageBullet_$NAME$_y[id]<MAP_MAXY) then
            call SetImagePosition(imageBullet_$NAME$_images[id],imageBullet_$NAME$_x[id],imageBullet_$NAME$_y[id],imageBullet_$NAME$_z[id])
        else
            set b=true
        endif
        set imageBullet_$NAME$_distance[id]=imageBullet_$NAME$_distance[id]-imageBullet_$NAME$_speed[id]
        if imageBullet_$NAME$_distance[id]<=0 then
            set b=true
            set g=CreateGroup()
            call GroupEnumUnitsInRange(g,imageBullet_$NAME$_x[id],imageBullet_$NAME$_y[id],imageBullet_$NAME$_range[id],null)
            loop
                set u = FirstOfGroup(g)
                exitwhen u == null
                if (GetUnitState(u,UNIT_STATE_LIFE)>0 and IsUnitEnemy(u,p)) then
                    // call Damage 此处为伤害动作
                endif
                call GroupRemoveUnit(g,u)
            endloop
        else
            set g=CreateGroup()
            call GroupEnumUnitsInRange(g,imageBullet_$NAME$_x[id],imageBullet_$NAME$_y[id],imageBullet_$NAME$_collision[id],null)

2011年03月16日 04点03分 3
level 1
秋瀞葉 楼主
            loop
                set u = FirstOfGroup(g)
                exitwhen u == null
                if (GetUnitState(u,UNIT_STATE_LIFE)>0 and IsUnitEnemy(u,p)) or b then
                    call GroupEnumUnitsInRange(g,imageBullet_$NAME$_x[id],imageBullet_$NAME$_y[id],imageBullet_$NAME$_range[id],null)
                    loop
                        set u = FirstOfGroup(g)
                        exitwhen u == null
                        if (GetUnitState(u,UNIT_STATE_LIFE)>0 and IsUnitEnemy(u,p)) then
                            // call Damage 此处为伤害动作
                        endif
                        call GroupRemoveUnit(g,u)
                    endloop
                    set b=true
                    exitwhen true
                endif
                call GroupRemoveUnit(g,u)
            endloop
        endif
        call DestroyGroup(g)
        set g = null
        if b then
            if imageBullet_$NAME$_targeteffpath[id]!=null then
                call DestroyEffect(AddSpecialEffect(imageBullet_$NAME$_targeteffpath[id],imageBullet_$NAME$_x[id],imageBullet_$NAME$_y[id]))
            endif
            call imageBullet_$NAME$_Delete(i)
        endif
        set i=i-1
    endloop
endfunction
function imageBullet_$NAME$_init takes nothing returns nothing
    set imageBullet_$NAME$_timer=CreateTimer()
    call TimerStart(imageBullet_$NAME$_timer,MOVEIMAGETIMER_TIMEOUT,true,function imageBullet_$NAME$_TimerAction)
endfunction
//! endtextmacro
// -------------
//! textmacro imageBulletsInit takes NAME,PATH,SIZE
set IMAGE_BULLETS_paths[$NAME$]="$PATH$"
set IMAGE_BULLETS_size[$NAME$]=$SIZE$
call imageBullet_$NAME$_init()
//! endtextmacro
globals
    real MOVEIMAGETIMER_TIMEOUT=0.04
    integer IMAGE_BULLET_PRELOAD_AMOUNT=50 //每次预创建数量
    string array IMAGE_BULLETS_paths
    real array IMAGE_BULLETS_size
    real MAP_MINX=-15594 //地图范围
    real MAP_MINY=-15860
    real MAP_MAXX=15578
    real MAP_MAXY=15342
endglobals
    //! runtextmacro imageBulletsFunction("1")
    // 参数为数字,做为下标
function IMAGE_BULLET_init takes nothing returns nothing
    //! runtextmacro imageBulletsInit("1","Cast_BallGreen.BLP","32")
    // 设置 1号图片弹幕 图片为Cast_BallGreen.BLP, 大小为32x32x32
endfunction
    // call imageBullet_1_New(spellunit,x,y,z,angle,speed,distance,effpath,collision,range,targeteffpath)
    // 发布弹幕的单位,坐标x,y,高度z,方向(弧度),速度,距离,路径特效(无则填null),碰撞半径,伤害范围,终点特效(无则填null)
    
2011年03月16日 04点03分 4
level 1
秋瀞葉 楼主
文本宏写的, - -用了预创建图片来做的.. 但是每种图片就得对应一个函数~~..
2011年03月16日 04点03分 5
level 15
[啊!][啊!][啊!][啊!][啊!][啊!][啊!][啊!][啊!]
2011年03月17日 12点03分 6
level 5
[惊讶]
2011年03月18日 05点03分 7
level 13
[啊!]v587
2011年03月19日 05点03分 8
level 1
秋瀞葉 楼主
[委屈]
2011年03月19日 23点03分 9
level 1
[Yeah]
2011年03月20日 02点03分 10
level 4
为何不用漂浮文字来做弹幕呢?
2012年01月02日 09点01分 11
level 15
回复11楼:难看,有最大上限,视角受限
2012年01月02日 11点01分 12
level 4
有木有兴趣用纯漂浮***个打灰机啊 我以前文曲星就有 很好玩的哦 而且代码也不难啊
2012年01月02日 11点01分 13
level 15
回复13楼:无聊
2012年01月02日 11点01分 14
level 4
::>_<::
2012年01月02日 11点01分 15
1