找回密码
 点一下
查看: 1684|回复: 3

war3中立刷兵同盟设置,参照dota(还有一些小细节没有处理)

[复制链接]
发表于 2012-9-17 00:30:25 | 显示全部楼层 |阅读模式
代码说明,CX是一方的玩具啊,TX是另一方的玩家,CT,AT分别是两个不同的队伍,AT是所有玩家,用来进行文字提示的玩家,CN,TN是玩家计数

[jass]
globals
player array CX
player array TX
force CT = CreateForce()
force TT = CreateForce()
force AT = CreateForce()
integer CN
integer TN
endglobals


function Player_Init takes nothing returns nothing
local integer i = 0
loop
    exitwhen i > 5
    set CX= Player(i)
    set i = i + 1
endloop
loop
    exitwhen i > 11
    set TX= Player(i)
    set i = i + 1
endloop
endfunction

function CountPlayerAdd_Child takes nothing returns nothing
if GetPlayerSlotState(GetEnumPlayer())==PLAYER_SLOT_STATE_PLAYING then
if GetEnumPlayer()!=Player(13)and GetEnumPlayer()!=Player(14)then
set bj_forceCountPlayers=bj_forceCountPlayers+1
endif
endif
endfunction
function CountPlayerAdd takes force f returns integer
set bj_forceCountPlayers=0
call ForForce(f,function CountPlayerAdd_Child)
return bj_forceCountPlayers
endfunction

function PlayerColorSet takes nothing returns nothing
call SetPlayerColor(CX[0],PLAYER_COLOR_RED)
call SetPlayerColor(CX[1],PLAYER_COLOR_BLUE)
call SetPlayerColor(CX[2],PLAYER_COLOR_CYAN)
call SetPlayerColor(CX[3],PLAYER_COLOR_PURPLE)
call SetPlayerColor(CX[4],PLAYER_COLOR_YELLOW)
call SetPlayerColor(CX[5],PLAYER_COLOR_ORANGE)
call SetPlayerColor(TX[0],PLAYER_COLOR_GREEN)
call SetPlayerColor(TX[1],PLAYER_COLOR_PINK)
call SetPlayerColor(TX[2],PLAYER_COLOR_LIGHT_GRAY)
call SetPlayerColor(TX[3],PLAYER_COLOR_LIGHT_BLUE)
call SetPlayerColor(TX[4],PLAYER_COLOR_AQUA)
call SetPlayerColor(TX[5],PLAYER_COLOR_BROWN)
endfunction
//下面还有带考究
function UnKnownCheck takes unit KAI returns boolean
local integer ID=GetUnitTypeId(KAI)
if ID==1848651862 or ID==1848651863 or ID==1848651826 or ID==1848651864 or ID==1849897784 or ID==1848652107 or

ID==1848651833 then
return true
endif
return true
endfunction
function ChangeUnitColor takes nothing returns nothing
if(GetOwningPlayer(GetEnumUnit())==Player(0))then
call SetUnitOwner(GetEnumUnit(),CX[0],false)
if UnKnownCheck (GetEnumUnit())==false then
call SetUnitColor(GetEnumUnit(),ConvertPlayerColor(0))
endif
else
call SetUnitOwner(GetEnumUnit(),TX[0],false)
if UnKnownCheck (GetEnumUnit())==false then
call SetUnitColor(GetEnumUnit(),ConvertPlayerColor(6))
endif
endif
endfunction
function ConditionTrue takes nothing returns boolean
return true
endfunction
//总是为true的返回
function InitUnitColor takes nothing returns nothing
local group g = CreateGroup()
call GroupEnumUnitsOfPlayer(g,Player(0),Condition(function ConditionTrue))
call ForGroup(g,function ChangeUnitColor)
call GroupClear(g)
call GroupEnumUnitsOfPlayer(g,Player(6),Condition(function ConditionTrue))
call ForGroup(g,function ChangeUnitColor)
call DestroyGroup(g)
endfunction
//把下面的函数地图初始化就好了
function TeamInit takes nothing returns nothing
local integer x=0
local integer y=0
local integer i
local boolean OB_STATE = false
call UnitInit()
set CX[0] = Player(0)
set TX[0] = Player(6)
// if player0 and player6 is ob
if GetPlayerState(CX[0],PLAYER_STATE_OBSERVER)!=0 or GetPlayerState(TX[0],PLAYER_STATE_OBSERVER)!=0 then
set OB_STATE=true
set CX[0]=Player(13)
set TX[0]=Player(14)
call SetAllyColorFilterState(0)
loop
exitwhen x>5
call SetPlayerAlliance(Player(0),CX[x],ConvertAllianceType(0),true)
call SetPlayerAlliance(Player(0),CX[x],ConvertAllianceType(4),true)
call SetPlayerAlliance(Player(0),TX[x],ConvertAllianceType(0),false)
call SetPlayerAlliance(Player(0),TX[x],ConvertAllianceType(4),false)
set x=x+1
endloop
endif
call ForceAddPlayer(CT,CX[0])
call ForceAddPlayer(CT,CX[1])
call ForceAddPlayer(CT,CX[2])
call ForceAddPlayer(CT,CX[3])
call ForceAddPlayer(CT,CX[4])
call ForceAddPlayer(CT,CX[5])
call ForceAddPlayer(TT,TX[0])
call ForceAddPlayer(TT,TX[1])
call ForceAddPlayer(TT,TX[2])
call ForceAddPlayer(TT,TX[3])
call ForceAddPlayer(TT,TX[4])
call ForceAddPlayer(TT,TX[5])
call ForceAddPlayer(AT,CX[1])
call ForceAddPlayer(AT,CX[2])
call ForceAddPlayer(AT,CX[3])
call ForceAddPlayer(AT,CX[4])
call ForceAddPlayer(AT,CX[5])
call ForceAddPlayer(AT,TX[1])
call ForceAddPlayer(AT,TX[2])
call ForceAddPlayer(AT,TX[3])
call ForceAddPlayer(AT,TX[4])
call ForceAddPlayer(AT,TX[5])
if OB_STATE then
call ForceAddPlayer(AT,Player(0))
call ForceAddPlayer(AT,Player(6))
endif
set x=0
set y=0
loop
exitwhen x>5
loop
exitwhen y>5
if(x!=y)then
call SetPlayerAlliance(CX[x],CX[y],ConvertAllianceType(0),true)
call SetPlayerAlliance(CX[x],CX[y],ConvertAllianceType(1),true)
call SetPlayerAlliance(CX[x],CX[y],ConvertAllianceType(2),true)
call SetPlayerAlliance(CX[x],CX[y],ConvertAllianceType(3),true)
call SetPlayerAlliance(CX[x],CX[y],ConvertAllianceType(4),true)
call SetPlayerAlliance(CX[x],CX[y],ConvertAllianceType(5),true)
call SetPlayerAlliance(CX[x],CX[y],ConvertAllianceType(6),false)
call SetPlayerAlliance(CX[x],CX[y],ConvertAllianceType(7),false)
call SetPlayerAlliance(TX[x],TX[y],ConvertAllianceType(0),true)
call SetPlayerAlliance(TX[x],TX[y],ConvertAllianceType(1),true)
call SetPlayerAlliance(TX[x],TX[y],ConvertAllianceType(2),true)
call SetPlayerAlliance(TX[x],TX[y],ConvertAllianceType(3),true)
call SetPlayerAlliance(TX[x],TX[y],ConvertAllianceType(4),true)
call SetPlayerAlliance(TX[x],TX[y],ConvertAllianceType(5),true)
call SetPlayerAlliance(TX[x],TX[y],ConvertAllianceType(6),false)
call SetPlayerAlliance(TX[x],TX[y],ConvertAllianceType(7),false)
call SetPlayerAlliance(CX[x],TX[y],ConvertAllianceType(0),false)
call SetPlayerAlliance(CX[x],TX[y],ConvertAllianceType(1),false)
call SetPlayerAlliance(CX[x],TX[y],ConvertAllianceType(2),false)
call SetPlayerAlliance(CX[x],TX[y],ConvertAllianceType(3),false)
call SetPlayerAlliance(CX[x],TX[y],ConvertAllianceType(4),false)
call SetPlayerAlliance(CX[x],TX[y],ConvertAllianceType(5),false)
call SetPlayerAlliance(CX[x],TX[y],ConvertAllianceType(6),false)
call SetPlayerAlliance(CX[x],TX[y],ConvertAllianceType(7),false)
call SetPlayerAlliance(TX[x],CX[y],ConvertAllianceType(0),false)
call SetPlayerAlliance(TX[x],CX[y],ConvertAllianceType(1),false)
call SetPlayerAlliance(TX[x],CX[y],ConvertAllianceType(2),false)
call SetPlayerAlliance(TX[x],CX[y],ConvertAllianceType(3),false)
call SetPlayerAlliance(TX[x],CX[y],ConvertAllianceType(4),false)
call SetPlayerAlliance(TX[x],CX[y],ConvertAllianceType(5),false)
call SetPlayerAlliance(TX[x],CX[y],ConvertAllianceType(6),false)
call SetPlayerAlliance(TX[x],CX[y],ConvertAllianceType(7),false)
endif
set y=y+1
endloop
set y=0
set x=x+1
endloop
call SetPlayerTeam(CX[0],0)
call SetPlayerTeam(CX[1],0)
call SetPlayerTeam(CX[2],0)
call SetPlayerTeam(CX[3],0)
call SetPlayerTeam(CX[4],0)
call SetPlayerTeam(CX[5],0)
call SetPlayerTeam(TX[0],1)
call SetPlayerTeam(TX[1],1)
call SetPlayerTeam(TX[2],1)
call SetPlayerTeam(TX[3],1)
call SetPlayerTeam(TX[4],1)
call SetPlayerTeam(TX[5],1)
if(CX[0]!=Player(0)or TX[0]!=Player(6))then
call InitUnitColor()
endif
call PlayerColorSet()
set CN=CountPlayerAdd(CT)
set TN=CountPlayerAdd(TT)
call SetPlayerHandicapXP(CX[1],1)
call SetPlayerHandicapXP(CX[2],1)
call SetPlayerHandicapXP(CX[3],1)
call SetPlayerHandicapXP(CX[4],1)
call SetPlayerHandicapXP(CX[5],1)
call SetPlayerHandicapXP(TX[1],1)
call SetPlayerHandicapXP(TX[2],1)
call SetPlayerHandicapXP(TX[3],1)
call SetPlayerHandicapXP(TX[4],1)
call SetPlayerHandicapXP(TX[5],1)
call SetPlayerState(CX[0],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(CX[1],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(CX[2],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(CX[3],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(CX[4],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(CX[5],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(TX[0],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(TX[1],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(TX[2],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(TX[3],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(TX[4],PLAYER_STATE_GIVES_BOUNTY,1)
call SetPlayerState(TX[5],PLAYER_STATE_GIVES_BOUNTY,1)
endfunction
[/jass]
上面的代码已经通过了检测,已经成功运行,在摆地图单位时,给玩家1和 玩家7就行, 会判断有没有裁判的情况,其实要把裁判的有无做全局变量,有时兵刷给14和15(Player(13)  和Player(14) ),没有就直接刷给1和7就行,以上代码是从dota里扣出来的,还要很多地方自己都看不太懂了 军训到10点半,接着搞这个3小时
发表于 2012-9-17 14:09:32 | 显示全部楼层
LZ是旺仔小馒头么
回复

使用道具 举报

 楼主| 发表于 2012-9-17 16:04:57 | 显示全部楼层
楼主还在苦逼军训,楼主在大新疆
回复

使用道具 举报

发表于 2012-9-26 16:38:30 | 显示全部楼层
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-28 12:12 , Processed in 0.101748 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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