如题,运算符 “~=”完全没见过也找不到也理解不能,是否是错的??不然的话是啥意思?还有就是Java脚本语言里边if else的使用规则和c里边一样么?比如说不加花括号的话只对之后的第一句有效。。else与上方最近的if对应?谢谢了,我的背景是c语言以及c++初学者。。全部代码如下,我认为首个if只判断是否给a赋值,之后的if else 构成了一个相当于switch语句的三选一的选择。。(注释原题无有,我自己加的)
GetRndNumber:获得随机数 GetBattleValue:获得指定旗标值
SetBattleValue:为指定旗标赋值 AtkToPlayer:攻击指定角色
GetRndPlayer:获得玩家id号 SetDamageScale:调整角色攻击力
function battle_ai004(npcID)
n=flag.GetBattleValue(15004) //把15004的旗标值赋给变量n
if n~=5 then //如果5按位取反赋值于n n=n~5为-6???此处可能是n^=5,当n值为5时候运算值为0,下一句不运行
a=battle.GetRndNumber(1,10) //对battle随机取1到10,赋给变量a。
if a>=1 and a<=6 then //如果a为1到6之间
n=n+1 //n++
flag.SetBattleValue(15004,n) //给flag15004赋n值
id = battle.GetRndPlayer() //把战斗中玩家的id号赋给变量id
battle.AtkToPlayer(id,1) //以1方式攻击该id号代表的player
else if a>=7 and a<=10 then //否则(不在1~6),如果a在7到10之间
id = battle.GetRndPlayer() //{把战斗中玩家的id号赋给变量id
battle.SetDamageScale(0.4) //把战斗中的角色攻击力调整0.4
battle.AtkToPlayer(id,2) //以方式2攻击该id号代表的player
flag.SetBattleValue(15004,0) //给flag15004赋0值
end
end
else //否则(即首个if不执行时以上两种选择之外)
id = battle.GetRndPlayer() //把战斗中玩家的id赋给变量id。
battle.SetDamageScale(0.4) //把战斗中的角色攻击力调整0.4
battle.AtkToPlayer(id,2) //以方式2攻击该id号代表的player
flag.SetBattleValue(15004,0) //给flag15004赋0值}}
end
end
谢谢了
以上。
GetRndNumber:获得随机数 GetBattleValue:获得指定旗标值
SetBattleValue:为指定旗标赋值 AtkToPlayer:攻击指定角色
GetRndPlayer:获得玩家id号 SetDamageScale:调整角色攻击力
function battle_ai004(npcID)
n=flag.GetBattleValue(15004) //把15004的旗标值赋给变量n
if n~=5 then //如果5按位取反赋值于n n=n~5为-6???此处可能是n^=5,当n值为5时候运算值为0,下一句不运行
a=battle.GetRndNumber(1,10) //对battle随机取1到10,赋给变量a。
if a>=1 and a<=6 then //如果a为1到6之间
n=n+1 //n++
flag.SetBattleValue(15004,n) //给flag15004赋n值
id = battle.GetRndPlayer() //把战斗中玩家的id号赋给变量id
battle.AtkToPlayer(id,1) //以1方式攻击该id号代表的player
else if a>=7 and a<=10 then //否则(不在1~6),如果a在7到10之间
id = battle.GetRndPlayer() //{把战斗中玩家的id号赋给变量id
battle.SetDamageScale(0.4) //把战斗中的角色攻击力调整0.4
battle.AtkToPlayer(id,2) //以方式2攻击该id号代表的player
flag.SetBattleValue(15004,0) //给flag15004赋0值
end
end
else //否则(即首个if不执行时以上两种选择之外)
id = battle.GetRndPlayer() //把战斗中玩家的id赋给变量id。
battle.SetDamageScale(0.4) //把战斗中的角色攻击力调整0.4
battle.AtkToPlayer(id,2) //以方式2攻击该id号代表的player
flag.SetBattleValue(15004,0) //给flag15004赋0值}}
end
end
谢谢了
以上。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货