找回密码
 点一下
查看: 1878|回复: 7

求个环绕函数 最好简单点的 我是新手

[复制链接]
发表于 2008-4-27 19:43:54 | 显示全部楼层 |阅读模式
就是创造N个单位 环绕某单位旋转
发表于 2008-4-27 20:20:56 | 显示全部楼层
那啥,帮找了半天没有可以偷懒的= =|||
回复

使用道具 举报

发表于 2008-4-27 20:32:43 | 显示全部楼层
环绕函数
是jass培训班教程里的
移植很方便的
1)把一些参数设定一下  诸如环绕时间 环绕半径等
2)调用CreateEwsp函数就行了


具体的 可以自己看演示

[JASS培训班素材]环绕技能模板.w3x

43 KB, 下载次数: 23

回复

使用道具 举报

发表于 2008-4-27 21:26:54 | 显示全部楼层
[codes=jass]function H2I takes handle h returns integer
    return h
    return 0
endfunction

function SetHandleHandle takes handle subject,string name,handle object returns nothing
    call StoreInteger(udg_gamecache,I2S(H2I(subject)),name,H2I(object))
endfunction

function GetHandleUnit takes handle subject,string name returns unit
    return GetStoredInteger(udg_gamecache,I2S(H2I(subject)),name)
    return null
endfunction

function Ewsp_LOOP takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit array tempUnit
    local real array angle
    local integer i = 0
    local unit orderUnit=GetHandleUnit(t,"orderUnit")
    local real UnitLocX = GetUnitX(orderUnit)
    local real UnitLocY = GetUnitY(orderUnit)
    local real tempLocX  
    local real tempLocY  
    local real a=0
    local real b=0
    local real zspeed = GetStoredInteger(udg_gamecache,I2S(H2I(t)),"zspeed")
    local real zangle = GetStoredInteger(udg_gamecache,I2S(H2I(t)),"zangle")
    local real xyspeed = GetStoredInteger(udg_gamecache,I2S(H2I(t)),"xyspeed")
    local real xyangle = GetStoredInteger(udg_gamecache,I2S(H2I(t)),"xyangle")
    local real radius = GetStoredReal(udg_gamecache,I2S(H2I(t)),"radius")
    local real N = GetStoredReal(udg_gamecache,I2S(H2I(t)),"number")
    local real S = GetStoredReal(udg_gamecache,I2S(H2I(t)),"speed")
    local integer steps= GetStoredInteger(udg_gamecache,I2S(H2I(t)),"steps")
    local integer count= GetStoredInteger(udg_gamecache,I2S(H2I(t)),"count")
    local location point_a
    local location point_b
    local real angle_a_b
    local real distance_a_b
    if steps<count  then     
      set steps=steps+1
      call StoreInteger(udg_gamecache,I2S(H2I(t)),"steps",steps)
      loop
          exitwhen i>N
          set i = i+1
          set a = steps * xyspeed + xyangle
          set b = steps * zspeed + zangle
          set tempUnit = GetHandleUnit(t,I2S(1000+i))
          set angle = i*360/N + steps*S

          set point_a = Location(UnitLocX,UnitLocY)
          set point_b = Location(UnitLocX + radius*CosBJ(angle)*CosBJ(b) , UnitLocY + radius*SinBJ(angle))
          set angle_a_b = AngleBetweenPoints(point_a,point_b)
          set distance_a_b = DistanceBetweenPoints(point_a,point_b)
          set tempLocX = UnitLocX + distance_a_b * CosBJ(angle_a_b + a)
          set tempLocY = UnitLocY + distance_a_b * SinBJ(angle_a_b + a)

          call SetUnitX(tempUnit,tempLocX)
          call SetUnitY(tempUnit,tempLocY)
          call SetUnitFlyHeightBJ( tempUnit,radius*CosBJ(angle)*SinBJ(b)+400, 0.00 )
          set tempUnit=null
          set point_a = null
          set point_b = null
      endloop
      call RemoveLocation(point_a)
      call RemoveLocation(point_b)
    else
        set i=0
        loop
            set i=i+1
            exitwhen i>N
            call RemoveUnit(GetHandleUnit(t,I2S(1000+i)))
        endloop
        call FlushStoredMission(udg_gamecache,I2S(H2I(t)))
        call DestroyTimer(t)
        call SetUnitFlyHeightBJ(orderUnit,1, 0.00 )
        call UnitRemoveAbilityBJ( 'Arav', orderUnit)
        call SetUnitScalePercent( orderUnit, 100, 100, 100 )
        call RemoveLocation(point_a)
        call RemoveLocation(point_b)
    endif
    set orderUnit=null
endfunction

function CreateEwsp takes unit Hero,integer ewsp,integer Z,integer ZAngle,integer XY,integer XYAngle,integer N,real R,real T,real I,real S returns nothing
    local unit orderUnit=Hero
    local real UnitLocX = GetUnitX(orderUnit)
    local real UnitLocY = GetUnitY(orderUnit)  
    local unit array tempUnit  
    local player Masterplayer = GetOwningPlayer(orderUnit)
    local timer t=CreateTimer()
    local real interval=I
    local real lasttime=T
    local real radius=R
    local real tempLocX  
    local real tempLocY
    local integer i=0
    local integer steps=R2I(lasttime/interval)
    call UnitAddAbilityBJ( 'Arav', Hero)
    call SetUnitFlyHeightBJ(Hero,400, 0.00 )
    call StoreInteger(udg_gamecache,I2S(H2I(t)),"zspeed",Z)
    call StoreInteger(udg_gamecache,I2S(H2I(t)),"zangle",ZAngle)
    call StoreInteger(udg_gamecache,I2S(H2I(t)),"xyspeed",XY)
    call StoreInteger(udg_gamecache,I2S(H2I(t)),"xyangle",XYAngle)
    call StoreInteger(udg_gamecache,I2S(H2I(t)),"count",steps)
    set steps=0
    call StoreInteger(udg_gamecache,I2S(H2I(t)),"steps",steps)
    call StoreReal(udg_gamecache,I2S(H2I(t)),"radius",radius)
    call StoreReal(udg_gamecache,I2S(H2I(t)),"number",N)
    call StoreReal(udg_gamecache,I2S(H2I(t)),"speed",S)
    loop
        set i=i+1
        exitwhen (i>N)
        set tempLocX = UnitLocX + radius*Cos(2*i*bj_PI/N)      
        set tempLocY = UnitLocY + radius*Sin(2*i*bj_PI/N)
        set tempUnit=CreateUnit(Masterplayer,ewsp,tempLocX,tempLocY,0)
        call SetUnitVertexColorBJ(tempUnit,GetRandomReal(0,100),GetRandomReal(0,100),GetRandomReal(0,100),0)
        call SetHandleHandle(t,I2S(1000+i),tempUnit)
        call UnitGenerateAlarms( tempUnit, false )
    endloop
   call SetHandleHandle(t,"orderUnit",orderUnit)
   call TimerStart(t,interval,true,function Ewsp_LOOP)
   set t=null   
   set orderUnit=null
   set i=0
   loop
       set i=i+1  
       exitwhen (i>N)
       set tempUnit=null
   endloop
endfunction


function Trig_a2_Actions takes nothing returns nothing
    local integer i = 0
    local integer array ewsp
    local integer count = GetRandomInt(1,2)
    local unit hero =null
    if ( not ( GetSpellAbilityId() == 'AOww' ) ) then
        return false
    endif
    set ewsp[0] = 'e001'
    set ewsp[1] = 'e002'
    set ewsp[2] = 'e000'
    set ewsp[3] = 'e003'
    set hero = GetTriggerUnit()
    call SetUnitScalePercent( hero, 2, 2, 2 )
    loop
        exitwhen i > count
        //CreateEwsp(触发单位,马甲类型,垂直翻转速度,垂直初始角度,水平旋转角度,水平初始角度,马甲数量,半径,持续时间,timer周期,水平自转速度)
        call  CreateEwsp(hero,ewsp[GetRandomInt(0,3)],GetRandomInt(0,6),GetRandomInt(0,9)*10,GetRandomInt(0,6),GetRandomInt(0,9)*10,24,GetRandomReal(2,4)*100,8,0.04,GetRandomInt(0,6))
        //call  CreateEwsp(hero,ewsp[1],3,0,0,0,24,250,8,0.04,6)
        //call  CreateEwsp(hero,ewsp[1],3,60,0,0,24,250,8,0.04,6)
        //call  CreateEwsp(hero,ewsp[1],3,120,0,0,24,250,8,0.04,6)
        //call  CreateEwsp(hero,ewsp[1],0,0,3,90,24,250,8,0.04,6)
        //call  CreateEwsp(hero,ewsp[1],0,60,3,90,24,250,8,0.04,6)
        //call  CreateEwsp(hero,ewsp[1],0,120,3,90,24,250,8,0.04,6)
        set i = i+1
   endloop
endfunction[/codes]
回复

使用道具 举报

发表于 2008-4-27 21:27:35 | 显示全部楼层
加强版
回复

使用道具 举报

 楼主| 发表于 2008-4-27 21:38:31 | 显示全部楼层
........
那个忒长...
看不懂咩..
回复

使用道具 举报

发表于 2008-4-27 22:09:27 | 显示全部楼层
看了下,3楼的代码格式十分清晰,应该不难读懂的,嗯~~

环绕么其实就是创建单位,然后用循环计时器每XX时间设置单位位置
从点(x0,y0)开始距离为l方向为a的点的坐标为(x0+l*cos a,y0+l*sin a)
利用这两点应该不难实现的
回复

使用道具 举报

发表于 2008-4-27 22:12:06 | 显示全部楼层
这个是效果

1.gif
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-9 17:46 , Processed in 0.073975 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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