找回密码
 点一下
查看: 3052|回复: 13

随机彩色单位  -_-!

[复制链接]
发表于 2007-10-25 01:41:38 | 显示全部楼层 |阅读模式
[codes=jass]function Trig_Color_Func001A takes nothing returns nothing
    call SetUnitVertexColorBJ( GetEnumUnit(), GetRandomPercentageBJ(), GetRandomPercentageBJ(), GetRandomPercentageBJ(), GetRandomPercentageBJ() )
endfunction

function Trig_Color_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsSelectedAll(GetTriggerPlayer()), function Trig_Color_Func001A )
    call TriggerSleepAction( 0.00 )
    call TriggerExecute( GetTriggeringTrigger() )
endfunction

//===========================================================================
function InitTrig_Color takes nothing returns nothing
    set gg_trg_Color = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Color, function Trig_Color_Actions )
endfunction[/codes]
额。。。利用WE自动生成的

评分

参与人数 1威望 +10 收起 理由
kook + 10 感谢分享

查看全部评分

 楼主| 发表于 2007-10-25 10:30:37 | 显示全部楼层
补一个JASS的
[codes=jass]
function Trig_Color_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsSelectedAll(GetTriggerPlayer()),SetUnitVertexColorBJ( GetEnumUnit(), GetRandomPercentageBJ(),GetRandomPercentageBJ(),GetRandomPercentageBJ(),GetRandomPercentageBJ()  )
    call TriggerSleepAction( 0.00 )
    call TriggerExecute( GetTriggeringTrigger() )
endfunction[/codes]
回复

使用道具 举报

发表于 2007-10-25 12:38:17 | 显示全部楼层
直接使用 GetUnitsSelectedAll 会有点麻烦,每次都会生成一个临时单位组

比较节省的方法是公用用一个空的全局单位组,然后在其filter 里执行
[codes=jass]globals
group CorlorfulSelectedUnits=null
endglobals

function varycolor takes nothing returns nothing
  call SetUnitVertexColor(GetFilterUnit(),GetRandomInt(0,255),GetRandomInt(0,255),GetRandomInt(0,255),GetRandomInt(0,255))
endfunction

function ColorAction takes nothing returns nothing
call GroupEnumUnitsSelected(CorlorfulSelectedUnits,GetTriggerPlayer(),Filter(function varycolor))
call TriggerSleepAction(x)
call TriggerExecute(GetTriggeringTrigger())
endfunction

function InitColor takes nothing returns nothing
set CorlorfulSelectedUnits=CreateGroup()
.....

[/codes]
回复

使用道具 举报

发表于 2007-10-25 12:40:30 | 显示全部楼层
不过,完全是随机跳变颜色的话,还是。。很不自然啊
回复

使用道具 举报

 楼主| 发表于 2007-10-25 12:41:59 | 显示全部楼层
感谢楼上指导~~
回复

使用道具 举报

发表于 2007-10-26 16:01:18 | 显示全部楼层
恩...厉害..完全看不懂
回复

使用道具 举报

发表于 2007-10-27 10:10:47 | 显示全部楼层
大概是明白了.......................   [s:127]
回复

使用道具 举报

发表于 2007-10-28 05:50:30 | 显示全部楼层
期待随机地形
回复

使用道具 举报

发表于 2007-11-14 14:34:31 | 显示全部楼层
??
是英雄的那种发光彩色吗?
回复

使用道具 举报

发表于 2007-11-14 17:07:24 | 显示全部楼层
引用第2楼kook于2007-10-25 12:38发表的  :
直接使用 GetUnitsSelectedAll 会有点麻烦,每次都会生成一个临时单位组

比较节省的方法是公用用一个空的全局单位组,然后在其filter 里执行
[jass]function NewGroup takes nothing returns group
   return bj_lastCreatedGroup
endfunction

function VaryColor takes nothing returns nothing
  call SetUnitVertexColor(GetFilterUnit(),GetRandomInt(0,255),GetRandomInt(0,255),GetRandomInt(0,255),GetRandomInt(0,255))
endfunction

function ColorAction takes nothing returns nothing
  call GroupEnumUnitsSelected(NewGroup(),GetTriggerPlayer(),Filter(function VaryColor))
  call TriggerSleepAction(x)
  call TriggerExecute(GetTriggeringTrigger())
endfunction[/jass]
公用是指这样吗
回复

使用道具 举报

发表于 2007-11-14 20:05:46 | 显示全部楼层
其实这个bj_lastCreatedGroup这样用是可以(本来bj_lastCreatedGroup就没什么用,destroy掉的风险很低),不过是借用bj变量不是很舒服。。
回复

使用道具 举报

发表于 2007-11-15 07:59:45 | 显示全部楼层
其实那样用是不可以的。。
首先。游戏开始不一定会创建一个bj_lastCreatedGroup。
然后。bj_lastCreatedGroup不是代表固定的单位组。因为每用BJ函数创建一个单位组,都会改变这个值。
所以。自己定义一个变量来保存KOOK说的固定的单位组,这样才是正确的。
回复

使用道具 举报

发表于 2007-11-15 10:41:47 | 显示全部楼层
引用第11楼amp34于2007-11-15 07:59发表的  :
其实那样用是不可以的。。
首先。游戏开始不一定会创建一个bj_lastCreatedGroup。
然后。bj_lastCreatedGroup不是代表固定的单位组。因为每用BJ函数创建一个单位组,都会改变这个值。
所以。自己定义一个变量来保存KOOK说的固定的单位组,这样才是正确的。
[jass]      // Last X'd vars
     unit               bj_lastCreatedUnit          = null
     item               bj_lastCreatedItem          = null
     item               bj_lastRemovedItem          = null
     unit               bj_lastHauntedGoldMine      = null
     destructable       bj_lastCreatedDestructable  = null
     group              bj_lastCreatedGroup         = CreateGroup()[/jass]

bj_lastCreatedGroup一开始就有默认值了

我都不用BJ的函数的...

我只喜欢用BJ的变量...
回复

使用道具 举报

发表于 2007-11-15 11:01:01 | 显示全部楼层
hmm。果然初始是有的。
如果楼主不用。那么这样当然也没错。不怕万一只怕一万而已。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-2 16:34 , Processed in 0.068635 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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