找回密码
 点一下
查看: 2326|回复: 11

一个骗分的函数

[复制链接]
发表于 2009-6-19 14:18:51 | 显示全部楼层 |阅读模式
范例函数:
call TargetUnitCheck(CheckUnit,CompareUnit,SUF_Enemy+SUF_Nature+SUF_NoneTarget)

/////////////////////////////
    constant integer            SUF_Ally = 2
    constant integer            SUF_Enemy = 4
    constant integer            SUF_Nature = 8
    constant integer            SUF_Flying = 16
    constant integer            SUF_Ground = 32
    constant integer            SUF_IsHero = 64
    constant integer            SUF_NotHero = 128
    constant integer            SUF_Alive = 256
    constant integer            SUF_Dead = 512
    constant integer            SUF_NoneSelf = 1024
    constant integer            SUF_NoneTarget = 2048
/////////////////////////////
function GetTuCheckCond takes integer i,integer cType returns boolean
    return Mod(i,cType*2)/cType==1
endfunction

function DoTuCheckCond takes integer i,integer cType,boolean chk,integer chkValue returns integer
    local integer c = 0
    local integer p = 0
    if(GetTuCheckCond(i,cType))then
        set c = 1
        if(chk)then
            set p = 1
    endif
    endif
    return IMax(chkValue/2,c)*2 + IMax(Mod(chkValue,2),p)
endfunction

function TargetUnitCheck takes unit cu,unit su,integer i returns boolean
    local integer chkValue = 0
    local boolean ally = IsUnitAlly(cu,GetOwningPlayer(su))
    local boolean enemy = IsUnitEnemy(cu,GetOwningPlayer(su))
    local boolean alive = GetUnitState(cu,UNIT_STATE_LIFE)>0
    if(GetTuCheckCond(i,SUF_NoneSelf) and cu==su)then
        return false
    endif
    if(GetTuCheckCond(i,SUF_NoneTarget) and cu==SYS_GroupTarget)then
        return false
    endif
    set chkValue = 0
    set chkValue = DoTuCheckCond(i,SUF_Alive,alive,chkValue)
    set chkValue = DoTuCheckCond(i,SUF_Dead,not(alive),chkValue)
    if(chkValue==2)then
        return false
    elseif(chkValue==0 and not(alive))then
        return false
    endif
    //============
    set chkValue = 0
    set chkValue = DoTuCheckCond(i,SUF_Ally,ally,chkValue)
    set chkValue = DoTuCheckCond(i,SUF_Enemy,enemy,chkValue)
    set chkValue = DoTuCheckCond(i,SUF_Nature,not(ally) and not(enemy),chkValue)
    if(chkValue==2)then
        return false
    endif
    //============
    set chkValue = 0
    set chkValue = DoTuCheckCond(i,SUF_IsHero,IsUnitType(cu,UNIT_TYPE_HERO),chkValue)
    set chkValue = DoTuCheckCond(i,SUF_NotHero,not(IsUnitType(cu,UNIT_TYPE_HERO)),chkValue)
    if(chkValue==2)then
        return false
    endif
    //============
    set chkValue = 0
    set chkValue = DoTuCheckCond(i,SUF_Flying,IsUnitType(cu,UNIT_TYPE_FLYING),chkValue)
    set chkValue = DoTuCheckCond(i,SUF_Ground,IsUnitType(cu,UNIT_TYPE_GROUND),chkValue)
    if(chkValue==2)then
        return false
    endif
    return true
endfunction
/////////////////////////////

评分

参与人数 1威望 +1 收起 理由
血戮魔动冰 + 1

查看全部评分

发表于 2009-6-19 14:40:10 | 显示全部楼层
米分弓虽大~~
回复

使用道具 举报

发表于 2009-6-19 15:48:46 | 显示全部楼层
作用呢?


TargetUnitCheck(Boss,10000)

这样就可以骗到分么~?
回复

使用道具 举报

 楼主| 发表于 2009-6-19 16:34:35 | 显示全部楼层
作用就是可以用一个int传递需要判断目标单位的类型。。

另外,楼上少了一个参数,会报错
回复

使用道具 举报

 楼主| 发表于 2009-6-19 16:38:00 | 显示全部楼层
其实这个函数还可以写的更优美一些
回复

使用道具 举报

发表于 2009-6-19 17:25:45 | 显示全部楼层
…………真囧…………想骗多少?嗯?
回复

使用道具 举报

 楼主| 发表于 2009-6-19 17:57:58 | 显示全部楼层
骗个一百来点威望吧。
(也许稍微的贪心了一点?)
回复

使用道具 举报

发表于 2009-6-19 19:39:18 | 显示全部楼层
呃,没弄懂。。。
EFF详细介绍下嗯~~
回复

使用道具 举报

发表于 2009-6-19 19:39:51 | 显示全部楼层
完全不能理解。。。其实我想抠走自己用
  [s:187]
回复

使用道具 举报

 楼主| 发表于 2009-6-19 23:33:11 | 显示全部楼层
修改了一下,相当有美感了。
回复

使用道具 举报

发表于 2009-6-20 17:54:44 | 显示全部楼层
用一个int传递需要判断目标单位的类型

这是啥,没看懂


还有,
/////////////////////////////
这东西完全没有美感- -
回复

使用道具 举报

 楼主| 发表于 2009-6-20 18:35:33 | 显示全部楼层
纯粹是模仿C_API写的。。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-24 08:53 , Processed in 0.145271 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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