diff --git a/src/bytecode.go b/src/bytecode.go index 149869709..1f63ef98d 100644 --- a/src/bytecode.go +++ b/src/bytecode.go @@ -203,7 +203,7 @@ const ( OC_hitfall OC_hitvel_x OC_hitvel_y - OC_roundsexisted + OC_player OC_parent OC_root OC_helper @@ -402,6 +402,7 @@ const ( OC_ex_matchover OC_ex_matchno OC_ex_roundno + OC_ex_roundsexisted OC_ex_ishometeam OC_ex_tickspersecond OC_ex_majorversion @@ -929,6 +930,13 @@ func (be BytecodeExp) run(c *Char) BytecodeValue { fallthrough case OC_jmp: i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4 + case OC_player: + if c = sys.playerID(c.getPlayerID(int(sys.bcStack.Pop().ToI()))); c != nil { + i += 4 + continue + } + sys.bcStack.Push(BytecodeSF()) + i += int(*(*int32)(unsafe.Pointer(&be[i]))) + 4 case OC_parent: if c = c.parent(); c != nil { i += 4 @@ -1259,8 +1267,6 @@ func (be BytecodeExp) run(c *Char) BytecodeValue { sys.bcStack.PushI(Rand(0, 999)) case OC_rightedge: sys.bcStack.PushF(c.rightEdge()) - case OC_roundsexisted: - sys.bcStack.PushI(c.roundsExisted()) case OC_roundstate: sys.bcStack.PushI(c.roundState()) case OC_screenheight: @@ -1755,6 +1761,8 @@ func (be BytecodeExp) run_ex(c *Char, i *int, oc *Char) { sys.bcStack.PushI(sys.match) case OC_ex_roundno: sys.bcStack.PushI(sys.round) + case OC_ex_roundsexisted: + sys.bcStack.PushI(c.roundsExisted()) case OC_ex_ishometeam: sys.bcStack.PushB(c.teamside == sys.home) case OC_ex_tickspersecond: diff --git a/src/compiler.go b/src/compiler.go index caf3b4427..52ab3299f 100644 --- a/src/compiler.go +++ b/src/compiler.go @@ -1160,7 +1160,7 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string, switch c.token { case "": return bvNone(), Error("Nothing assigned") - case "root", "parent", "helper", "target", "partner", + case "root", "player", "parent", "helper", "target", "partner", "enemy", "enemynear", "playerid": switch c.token { case "parent": @@ -1171,6 +1171,8 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string, c.token = c.tokenizer(in) default: switch c.token { + case "player": + opc = OC_player case "helper": opc = OC_helper case "target": @@ -1201,6 +1203,8 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string, be1.appendValue(BytecodeInt(-1)) case OC_partner, OC_enemy, OC_enemynear: be1.appendValue(BytecodeInt(0)) + case OC_player: + return bvNone(), Error("Missing '(' after player") case OC_playerid: return bvNone(), Error("Missing '(' after playerid") } @@ -2014,7 +2018,7 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string, case "roundno": out.append(OC_ex_, OC_ex_roundno) case "roundsexisted": - out.append(OC_roundsexisted) + out.append(OC_ex_, OC_ex_roundsexisted) case "roundstate": out.append(OC_roundstate) case "screenheight":