魔兽争霸三地图编辑器版本:1.24e(6059)
分析了两个大学时代经常用于消磨时间的TD案例:
1、华理TD
2、人族无敌
config函数作为地图脚本的其中一个入口函数,承担着War3创建地图之后的房间界面的规则初始化工作,下面以人族无敌的地图规则脚本为例进行分析:
如图中我们所见到的信息及相应的规则设置。
下面我们分析下具体在config函数中都做了哪些事情:
1 //*************************************************************************** 2 //* 3 //* Map Configuration 4 //* 5 //*************************************************************************** 6 7 function config takes nothing returns nothing 8 call SetMapName( "TRIGSTR_017" ) // 设置地图名称 9 call SetMapDescription( "TRIGSTR_323" ) // 设置地图描述 10 call SetPlayers( 7 ) // 设置玩家个数 11 call SetTeams( 7 ) // 设置队伍个数 12 call SetGamePlacement( MAP_PLACEMENT_TEAMS_TOGETHER ) // 设置将联盟的玩家放置在一起 13 14 call DefineStartLocation( 0, -5120.0, -3200.0 ) // 定义出生点 15 call DefineStartLocation( 1, 4544.0, -2688.0 ) 16 call DefineStartLocation( 2, 2752.0, 3520.0 ) 17 call DefineStartLocation( 3, -3264.0, 3072.0 ) 18 call DefineStartLocation( 4, -1216.0, -5888.0 ) 19 call DefineStartLocation( 5, -384.0, -5888.0 ) 20 call DefineStartLocation( 6, -832.0, -512.0 ) 21 22 // Player setup 23 call InitCustomPlayerSlots( ) // 设置玩家栏位属性 24 call InitCustomTeams( ) // 设置队伍属性 25 call InitAllyPriorities( ) // 设置联盟优先级 26 endfunction
1 function InitCustomPlayerSlots takes nothing returns nothing 2 3 // Player 0 4 call SetPlayerStartLocation( Player(0), 0 ) // 设置玩家出生点 5 call ForcePlayerStartLocation( Player(0), 0 ) // 强制设置玩家出生点位置 6 call SetPlayerColor( Player(0), ConvertPlayerColor(0) ) // 设置玩家颜色 7 call SetPlayerRacePreference( Player(0), RACE_PREF_HUMAN ) // 设置玩家种族为人族 8 call SetPlayerRaceSelectable( Player(0), false ) // 设置玩家不可以修改种族属性 9 call SetPlayerController( Player(0), MAP_CONTROL_USER ) // 设置玩家控制者为玩家 10 11 // Player 1 12 call SetPlayerStartLocation( Player(1), 1 ) 13 call ForcePlayerStartLocation( Player(1), 1 ) 14 call SetPlayerColor( Player(1), ConvertPlayerColor(1) ) 15 call SetPlayerRacePreference( Player(1), RACE_PREF_HUMAN ) 16 call SetPlayerRaceSelectable( Player(1), false ) 17 call SetPlayerController( Player(1), MAP_CONTROL_USER ) 18 19 // Player 2 20 call SetPlayerStartLocation( Player(2), 2 ) 21 call ForcePlayerStartLocation( Player(2), 2 ) 22 call SetPlayerColor( Player(2), ConvertPlayerColor(2) ) 23 call SetPlayerRacePreference( Player(2), RACE_PREF_HUMAN ) 24 call SetPlayerRaceSelectable( Player(2), false ) 25 call SetPlayerController( Player(2), MAP_CONTROL_USER ) 26 27 // Player 3 28 call SetPlayerStartLocation( Player(3), 3 ) 29 call ForcePlayerStartLocation( Player(3), 3 ) 30 call SetPlayerColor( Player(3), ConvertPlayerColor(3) ) 31 call SetPlayerRacePreference( Player(3), RACE_PREF_HUMAN ) 32 call SetPlayerRaceSelectable( Player(3), false ) 33 call SetPlayerController( Player(3), MAP_CONTROL_USER ) 34 35 // Player 9 36 call SetPlayerStartLocation( Player(9), 4 ) 37 call ForcePlayerStartLocation( Player(9), 4 ) 38 call SetPlayerColor( Player(9), ConvertPlayerColor(9) ) 39 call SetPlayerRacePreference( Player(9), RACE_PREF_UNDEAD ) // 设置玩家种族为不死族 40 call SetPlayerRaceSelectable( Player(9), false ) 41 call SetPlayerController( Player(9), MAP_CONTROL_COMPUTER ) // 设置玩家控制方式为电脑控制 42 43 // Player 10 44 call SetPlayerStartLocation( Player(10), 5 ) 45 call ForcePlayerStartLocation( Player(10), 5 ) 46 call SetPlayerColor( Player(10), ConvertPlayerColor(10) ) 47 call SetPlayerRacePreference( Player(10), RACE_PREF_HUMAN ) 48 call SetPlayerRaceSelectable( Player(10), false ) 49 call SetPlayerController( Player(10), MAP_CONTROL_COMPUTER ) 50 51 // Player 11 52 call SetPlayerStartLocation( Player(11), 6 ) 53 call ForcePlayerStartLocation( Player(11), 6 ) 54 call SetPlayerColor( Player(11), ConvertPlayerColor(11) ) 55 call SetPlayerRacePreference( Player(11), RACE_PREF_UNDEAD ) 56 call SetPlayerRaceSelectable( Player(11), false ) 57 call SetPlayerController( Player(11), MAP_CONTROL_COMPUTER ) 58 59 endfunction
1 function InitCustomTeams takes nothing returns nothing 2 // Force: Maze Defenders 3 call SetPlayerTeam( Player(0), 0 ) // 设置玩家组队属性 4 call SetPlayerTeam( Player(1), 0 ) 5 call SetPlayerTeam( Player(2), 0 ) 6 call SetPlayerTeam( Player(3), 0 ) 7 8 // Allied 9 call SetPlayerAllianceStateAllyBJ( Player(0), Player(1), true ) // 设置玩家结盟属性 10 call SetPlayerAllianceStateAllyBJ( Player(0), Player(2), true ) 11 call SetPlayerAllianceStateAllyBJ( Player(0), Player(3), true ) 12 call SetPlayerAllianceStateAllyBJ( Player(1), Player(0), true ) 13 call SetPlayerAllianceStateAllyBJ( Player(1), Player(2), true ) 14 call SetPlayerAllianceStateAllyBJ( Player(1), Player(3), true ) 15 call SetPlayerAllianceStateAllyBJ( Player(2), Player(0), true ) 16 call SetPlayerAllianceStateAllyBJ( Player(2), Player(1), true ) 17 call SetPlayerAllianceStateAllyBJ( Player(2), Player(3), true ) 18 call SetPlayerAllianceStateAllyBJ( Player(3), Player(0), true ) 19 call SetPlayerAllianceStateAllyBJ( Player(3), Player(1), true ) 20 call SetPlayerAllianceStateAllyBJ( Player(3), Player(2), true ) 21 22 // Shared Vision 23 call SetPlayerAllianceStateVisionBJ( Player(0), Player(1), true ) // 设置玩家共享视野属性 24 call SetPlayerAllianceStateVisionBJ( Player(0), Player(2), true ) 25 call SetPlayerAllianceStateVisionBJ( Player(0), Player(3), true ) 26 call SetPlayerAllianceStateVisionBJ( Player(1), Player(0), true ) 27 call SetPlayerAllianceStateVisionBJ( Player(1), Player(2), true ) 28 call SetPlayerAllianceStateVisionBJ( Player(1), Player(3), true ) 29 call SetPlayerAllianceStateVisionBJ( Player(2), Player(0), true ) 30 call SetPlayerAllianceStateVisionBJ( Player(2), Player(1), true ) 31 call SetPlayerAllianceStateVisionBJ( Player(2), Player(3), true ) 32 call SetPlayerAllianceStateVisionBJ( Player(3), Player(0), true ) 33 call SetPlayerAllianceStateVisionBJ( Player(3), Player(1), true ) 34 call SetPlayerAllianceStateVisionBJ( Player(3), Player(2), true ) 35 36 // Force: Maze Attackers 37 call SetPlayerTeam( Player(9), 1 ) 38 call SetPlayerTeam( Player(11), 1 ) 39 40 // Shared Vision 41 call SetPlayerAllianceStateVisionBJ( Player(9), Player(11), true ) 42 call SetPlayerAllianceStateVisionBJ( Player(11), Player(9), true ) 43 44 // Force: Lives 45 call SetPlayerTeam( Player(10), 2 ) 46 47 endfunction
1 function InitAllyPriorities takes nothing returns nothing 2 3 call SetStartLocPrioCount( 0, 3 ) // 设置玩家结盟优先级 4 call SetStartLocPrio( 0, 0, 1, MAP_LOC_PRIO_HIGH ) 5 call SetStartLocPrio( 0, 1, 2, MAP_LOC_PRIO_HIGH ) 6 call SetStartLocPrio( 0, 2, 3, MAP_LOC_PRIO_HIGH ) 7 8 call SetStartLocPrioCount( 1, 3 ) 9 call SetStartLocPrio( 1, 0, 0, MAP_LOC_PRIO_HIGH ) 10 call SetStartLocPrio( 1, 1, 2, MAP_LOC_PRIO_HIGH ) 11 call SetStartLocPrio( 1, 2, 3, MAP_LOC_PRIO_HIGH ) 12 13 call SetStartLocPrioCount( 2, 3 ) 14 call SetStartLocPrio( 2, 0, 0, MAP_LOC_PRIO_HIGH ) 15 call SetStartLocPrio( 2, 1, 1, MAP_LOC_PRIO_HIGH ) 16 call SetStartLocPrio( 2, 2, 3, MAP_LOC_PRIO_HIGH ) 17 18 call SetStartLocPrioCount( 3, 3 ) 19 call SetStartLocPrio( 3, 0, 0, MAP_LOC_PRIO_HIGH ) 20 call SetStartLocPrio( 3, 1, 1, MAP_LOC_PRIO_HIGH ) 21 call SetStartLocPrio( 3, 2, 2, MAP_LOC_PRIO_HIGH ) 22 endfunction
以能立能达为体,以不怨不尤为用。