永恒的灌水帝吧 关注:586贴子:1,695
  • 14回复贴,共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)



1楼2011-03-16 12:47回复
            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
    


    2楼2011-03-16 12:47
    回复
      2025-05-10 09:10:39
      广告
              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)
      


      3楼2011-03-16 12:47
      回复
                    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)
            


        4楼2011-03-16 12:47
        回复
          文本宏写的, - -用了预创建图片来做的.. 但是每种图片就得对应一个函数~~..


          5楼2011-03-16 12:48
          回复
            


            IP属地:广东6楼2011-03-17 20:56
            回复


              IP属地:浙江7楼2011-03-18 13:05
              回复
                v587


                IP属地:天津8楼2011-03-19 13:16
                回复
                  2025-05-10 09:04:39
                  广告


                  9楼2011-03-20 07:06
                  回复


                    10楼2011-03-20 10:47
                    回复
                      为何不用漂浮文字来做弹幕呢?


                      IP属地:安徽来自掌上百度11楼2012-01-02 17:13
                      回复
                        回复11楼:难看,有最大上限,视角受限


                        IP属地:广东来自iPhone客户端12楼2012-01-02 19:43
                        回复
                          有木有兴趣用纯漂浮***个打灰机啊 我以前文曲星就有 很好玩的哦 而且代码也不难啊


                          IP属地:安徽来自掌上百度13楼2012-01-02 19:49
                          回复
                            回复13楼:无聊


                            IP属地:广东来自iPhone客户端14楼2012-01-02 19:52
                            回复
                              2025-05-10 08:58:39
                              广告
                              ::>_<::


                              IP属地:安徽来自掌上百度15楼2012-01-02 19:54
                              回复