全局变量定义一般至于脚本的开始位置,按照生成方式分为两个部分:自定义变量和系统自动生成变量。
1 //*************************************************************************** 2 //* 3 //* Global Variables 4 //* 5 //*************************************************************************** 6 7 globals 8 // User-defined 9 integer array udg_Kills 10 boolean udg_defeated = false 11 . 12 . 13 . 14 // Generated 15 rect gg_rct_Bottom_Left_End = null 16 rect gg_rct_Bottom_Left_WP_1o1 = null 17 . 18 . 19 . 20 endglobals
上面列举出了人族无敌脚本的部分变量定义。从中我们可以看到全局变量定义的语句块关键字为
globals
endglobals
War3场景规则脚本的变量类型较多除了常见的基础变量类型外,为了方面暴雪还提供了很多自定义变量类型,下面给出脚本中可以用的变量类型及其简要说明:
变量名 | 描述 | 默认值 |
integer | 技能(这里就是整形估计为技能ID) | 0 |
attacktype | 攻击类型 | null |
boolean | 布尔型 | FALSE |
integer | 魔法效果 | 0 |
camerasetup | 镜头物体 | null |
weapontype | 战斗声音 | null |
damagetype | 攻击类型 | null |
destructable | 可破坏的 | null |
integer | 可破坏的-类型 | 0 |
defeatcondition | 失败条件 | null |
dialog | 对话 | null |
button | 对话按钮 | null |
effecttype | 效果类型 | null |
texttag | 漂浮文字 | null |
gamecache | 游戏缓存 | null |
gamespeed | 游戏速度 | null |
handle | 控制码 | null |
hashtable | 哈希表 | null |
image | 图像 | null |
integer | 图像类型 | 0 |
integer | 布尔值 | 0 |
item | 物品 | null |
itemtype | 物品类 | null |
integer | 物品-类型 | 0 |
leaderboard | 排行榜 | null |
lightning | 闪电 | null |
string | 闪电类型 | 无 |
multiboard | 多面板 | null |
integer | 命令 | 0 |
player | 玩家 | null |
playercolor | 玩家颜色 | null |
force | 玩家组 | null |
location | 点 | null |
pathingtype | 道路类型 | null |
quest | 任务 | null |
questitem | 任务要求 | null |
race | 种族 | null |
real | 浮点型 | 0 |
rect | 区域 | null |
sound | 声音 | null |
soundtype | 声音类型 | null |
effect | 特效 | null |
string | 字符串 | 无 |
integer | 科技-类型 | 0 |
terraindeformation | 地形变形 | null |
integer | 地形形状 | 0 |
integer | 地形类型 | 0 |
timer | 计时器 | null |
timerdialog | 计时器窗口 | null |
trigger | 触发器 | null |
ubersplat | 间隔 | null |
string | 间隔类型 | 无 |
unit | 单位 | null |
group | 单位组 | null |
integer | 单位-类型 | 0 |
fogmodifier | 战争迷雾修改器 | null |
weathereffect | 气候效果 | null |
从场景规则自动生成的脚本情况来看,War3的脚本系统提倡在文件的开头对整个脚本中用到的变量进行统一的定义,在脚本的其他函数中并未见到任何变量的定义,所以我们在修改场景规则脚本的时候尽量按照暴雪的编码风格对脚本进行扩展。
时间问题,本文章就分析到此,后期如有时间将对暴雪提供的复合型变量逐一进行分析并给出使用说明。