找回密码
 点一下
查看: 1256|回复: 16

如何关于单位移动的距离

[复制链接]
发表于 2012-6-24 18:47:38 | 显示全部楼层 |阅读模式
弄技能的遇到了困扰
一、如何判断单位移动的距离,例如每移动150码制造一个分身。
二、召唤一个守卫,在这个守卫1000码内魔免且让自己周围的敌人伤血每秒,但是守卫被破坏或者自己移动距离达到1000码时自动消失
三、如何让单位冲刺技能时不会冲过黑色的那些无法通行的技能!
求高手指教!!!
发表于 2012-6-24 19:17:03 | 显示全部楼层
   循环判定单位的上一次点和这次点的位置。加起来就可以了
回复

使用道具 举报

 楼主| 发表于 2012-6-24 21:18:24 | 显示全部楼层
给个演示行不?弱弱说一句不要UI的
回复

使用道具 举报

发表于 2012-6-24 22:36:10 | 显示全部楼层
allennai:给个演示行不?弱弱说一句不要UI的 (2012-06-24 21:18)
整数变量里的动作有“点到点之间的距离”

只要每隔XX秒先把新算出来的距离与之前存的距离加起来,然后判断是否大于等于某个值,是的话做动作就行了~
PS:动作里要将那个整数变量设成已存距离 - 某个值(上面用来判断的那个)
回复

使用道具 举报

 楼主| 发表于 2012-6-25 05:40:13 | 显示全部楼层
给个触发看看吧
回复

使用道具 举报

 楼主| 发表于 2012-6-27 19:01:01 | 显示全部楼层
第三个问题啊!!!
回复

使用道具 举报

发表于 2012-6-27 19:15:08 | 显示全部楼层
第不是可以在移动之前判断移动后是否在可用地图范围内吗
回复

使用道具 举报

 楼主| 发表于 2012-6-28 13:53:24 | 显示全部楼层
怎么判断?给个演示看看
回复

使用道具 举报

发表于 2012-6-28 18:11:25 | 显示全部楼层
我只有YDWE,看不了找别人吧 滑动的傻馒.w3x (158 KB, 下载次数: 8)
回复

使用道具 举报

发表于 2012-6-28 19:19:24 | 显示全部楼层
不应该是判断目标地面是否可通行?
回复

使用道具 举报

发表于 2012-6-28 19:44:27 | 显示全部楼层
LZ说的黑色区域是地图外面的那块黑色的部位喔,momo
话说都可以哈
回复

使用道具 举报

 楼主| 发表于 2012-6-29 03:32:41 | 显示全部楼层
边缘的黑色部分,可以穿越的,怎么弄只可以穿越地形不穿越黑色部分!
回复

使用道具 举报

发表于 2012-6-29 08:43:35 | 显示全部楼层
说的方法都可以啊
回复

使用道具 举报

发表于 2012-6-29 09:42:56 | 显示全部楼层
可以根据地图可用区域获取地图边界坐标,移动的时候判断坐标是否在可用区域内就可以了
回复

使用道具 举报

发表于 2012-6-29 10:24:30 | 显示全部楼层
[jass]//-----------地图边界警卫

library BoundSentinel initializer init
//*************************************************
//* BoundSentinel
//* -------------
//* 地图边界警卫
//*  Don't leave your units unsupervised, naughty
//* them may try to get out of the map bounds and
//* crash your game.
//*     不要让你的单位处于无人监督的状态,生性顽皮
//*    的他们可能会试着跑出地图边界继而使你的游戏崩溃.
//*
//*  To implement, just get a vJass compiler and
//* copy this library/trigger to your map.
//*     想运用该库,只需要一个VJass编译程序,并且复制
//* 该库到你的地图中即可.
//*
//*************************************************

//==================================================
       globals
       // High enough so the unit is no longer visible, low enough so the
       // game doesn't crash...
       // 该值太大单位不再处于可见状态,足够小游戏将不会崩溃.
       //
       // I think you need 0.0 or something negative prior to patch 1.22
       // 如果是在魔兽1.22补丁以前,我想你需要设置该值为0.00或者为负数.
       //  
           private constant real EXTRA = 100.0
       endglobals

   //=========================================================================================
       globals
           private real maxx
           private real maxy
           private real minx
           private real miny
       endglobals

   //=======================================================================
       private function dis takes nothing returns boolean
        local unit u=GetTriggerUnit()
        local real x=GetUnitX(u)
        local real y=GetUnitY(u)

           if(x>maxx) then
               set x=maxx
           elseif(x<minx) then
               set x=minx
           endif
           if(y>maxy) then
               set y=maxy
           elseif(y<miny) then
               set y=miny
           endif
           call SetUnitX(u,x)
           call SetUnitY(u,y)
        set u=null
        return false
    endfunction

       private function init takes nothing returns nothing
        local trigger t=CreateTrigger()
        local region  r=CreateRegion()
        local rect    rc

           set minx=GetCameraBoundMinX() - EXTRA
           set miny=GetCameraBoundMinY() - EXTRA
           set maxx=GetCameraBoundMaxX() + EXTRA
           set maxy=GetCameraBoundMaxY() + EXTRA
           set rc=Rect(minx,miny,maxx,maxy)
           call RegionAddRect(r, rc)
           call RemoveRect(rc)

           call TriggerRegisterLeaveRegion(t,r,Condition(function dis))

    //this is not necessary but I'll do it anyway:
        set t=null
        set r=null
        set rc=null
       endfunction
endlibrary[/jass]
回复

使用道具 举报

发表于 2012-6-29 10:50:38 | 显示全部楼层
[jass]library TerrainPathability initializer Init
//******************************************************************************
//* BY: Rising_Dusk
//*
//* This script can be used to detect the type of pathing at a specific point.
//* It is valuable to do it this way because the IsTerrainPathable is very
//* counterintuitive and returns in odd ways and aren't always as you would
//* expect. This library, however, facilitates detecting those things reliably
//* and easily.
//*
//******************************************************************************
//*
//*    > function IsTerrainDeepWater    takes real x, real y returns boolean
//      判断坐标x,y处地形是否处于深水
//*    > function IsTerrainShallowWater takes real x, real y returns boolean
//      判断坐标x,y处地形是否处于浅水
//*    > function IsTerrainLand         takes real x, real y returns boolean
//      判断坐标x,y处地形是否处于陆地
//*    > function IsTerrainPlatform     takes real x, real y returns boolean
//      判断坐标x,y处地形是否处于不可见平台
//*    > function IsTerrainWalkable     takes real x, real y returns boolean
//      判断坐标x,y处地形的可行性
//*
//* These functions return true if the given point is of the type specified
//* in the function's name and false if it is not. For the IsTerrainWalkable
//* function, the MAX_RANGE constant below is the maximum deviation range from
//* the supplied coordinates that will still return true.
//*
//* The IsTerrainPlatform works for any preplaced walkable destructable. It will
//* return true over bridges, destructable ramps, elevators, and invisible
//* platforms. Walkable destructables created at runtime do not create the same
//* pathing hole as preplaced ones do, so this will return false for them. All
//* other functions except IsTerrainWalkable return false for platforms, because
//* the platform itself erases their pathing when the map is saved.
//*
//* After calling IsTerrainWalkable(x, y), the following two global variables
//* gain meaning. They return the X and Y coordinates of the nearest walkable
//* point to the specified coordinates. These will only deviate from the
//* IsTerrainWalkable function arguments if the function returned false.
//*
//* Variables that can be used from the library:
//*     [real]    TerrainPathability_X
//*     [real]    TerrainPathability_Y
//*
    globals
        private constant real    MAX_RANGE     = 10.
        private constant integer DUMMY_ITEM_ID = 'wolg'
    endglobals

    globals   
        private item       Item   = null
        private rect       Find   = null
        private item array Hid
        private integer    HidMax = 0
        public  real       X      = 0.
        public  real       Y      = 0.
    endglobals

    function IsTerrainDeepWater takes real x, real y returns boolean
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    endfunction
   
    function IsTerrainShallowWater takes real x, real y returns boolean
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
    endfunction
   
    function IsTerrainLand takes real x, real y returns boolean
        return IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY)
    endfunction
   
    function IsTerrainPlatform takes real x, real y returns boolean
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
    endfunction

    private function HideItem takes nothing returns nothing
        if IsItemVisible(GetEnumItem()) then
            set Hid[HidMax] = GetEnumItem()
            call SetItemVisible(Hid[HidMax], false)
            set HidMax = HidMax + 1
        endif
    endfunction
   
    function IsTerrainWalkable takes real x, real y returns boolean
        //Hide any items in the area to avoid conflicts with our item
        call MoveRectTo(Find, x, y)
        call EnumItemsInRect(Find ,null, function HideItem)
        //Try to move the test item and get its coords
        call SetItemPosition(Item, x, y) //Unhides the item
        set X = GetItemX(Item)
        set Y = GetItemY(Item)
        static if LIBRARY_IsTerrainWalkable then
            //This is for compatibility with the IsTerrainWalkable library
            set IsTerrainWalkable_X = X
            set IsTerrainWalkable_Y = Y
        endif
        call SetItemVisible(Item, false)//Hide it again
        //Unhide any items hidden at the start
        loop
            exitwhen HidMax <= 0
            set HidMax = HidMax - 1
            call SetItemVisible(Hid[HidMax], true)
            set Hid[HidMax] = null
        endloop
        //Return walkability
        return (X-x)*(X-x)+(Y-y)*(Y-y) <= MAX_RANGE*MAX_RANGE and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    endfunction

    private function Init takes nothing returns nothing
        set Find = Rect(0., 0., 128., 128.)
        set Item = CreateItem(DUMMY_ITEM_ID, 0, 0)
        call SetItemVisible(Item, false)
    endfunction
   
endlibrary[/jass]
回复

使用道具 举报

 楼主| 发表于 2012-6-29 12:21:08 | 显示全部楼层
别和我扯JASS,我完全不懂
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-1 10:05 , Processed in 0.237647 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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