Skip to content

Commit

Permalink
Add player() trigger redirection
Browse files Browse the repository at this point in the history
Needed for 66b82d0
  • Loading branch information
Lazin3ss committed Dec 7, 2022
1 parent 66b82d0 commit 5feab71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/bytecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const (
OC_hitfall
OC_hitvel_x
OC_hitvel_y
OC_roundsexisted
OC_player
OC_parent
OC_root
OC_helper
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions src/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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":
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 5feab71

Please sign in to comment.