Skip to content

Commit

Permalink
Triple pair (#143)
Browse files Browse the repository at this point in the history
* Add triple pair

---------

Co-authored-by: Crystalwarrior <[email protected]>
  • Loading branch information
EstatoDeviato and Crystalwarrior authored May 27, 2024
1 parent 5f3fd54 commit b2de61b
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 3 deletions.
26 changes: 24 additions & 2 deletions server/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,13 @@ def send_ic(self,
frames_realization="",
frames_sfx="",
additive=0,
effect="", targets=None):
effect="",
targets=None,
third_charid=-1,
third_folder="",
third_emote=0,
third_offset="",
third_flip=0):
"""
Send an IC message from a client to all applicable clients in the area.
:param client: speaker
Expand Down Expand Up @@ -1077,6 +1083,7 @@ def send_ic(self,
# We're in a minigame w/ team setups
if opposing_team is not None:
charid_pair = -1
third_charid = -1
# Last speaker is us and our message already paired us with someone, and that someone is on the opposing team
if (
client.area.last_ic_message is not None
Expand Down Expand Up @@ -1183,7 +1190,12 @@ def send_ic(self,
frames_realization,
frames_sfx,
additive,
effect)
effect,
third_charid,
third_folder,
third_emote,
third_offset,
third_flip)
if self.recording:
# See if the testimony is supposed to end here.
scrunched = "".join(e for e in msg if e.isalnum())
Expand Down Expand Up @@ -1233,6 +1245,11 @@ def send_ic(self,
frames_sfx, # 27
additive, # 28
effect, # 29
third_charid, # 30
third_folder, # 31
third_emote, # 32
third_offset, # 33
third_flip, # 34
)
self.last_ic_message = args

Expand Down Expand Up @@ -1287,6 +1304,11 @@ def send_ic(self,
frames_sfx, # 27
additive, # 28
effect, # 29
third_charid, # 30
third_folder, # 31
third_emote, # 32
third_offset, # 33
third_flip, # 34
)
if idx == -1:
# Add one statement at the very end.
Expand Down
1 change: 1 addition & 0 deletions server/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, server, transport, user_id, ipid):

# Pairing character ID
self.charid_pair = -1
self.third_charid = -1
# Override if using the /pair command will lock "charid_pair" from being changed by MS packet
self.charid_pair_override = False
# Pairing order, either 0 (in front) or 1 (behind)
Expand Down
31 changes: 31 additions & 0 deletions server/commands/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"ooc_cmd_switch",
"ooc_cmd_pos",
"ooc_cmd_pair",
"ooc_cmd_triple_pair",
"ooc_cmd_unpair",
"ooc_cmd_pair_order",
"ooc_cmd_forcepos",
Expand Down Expand Up @@ -1226,3 +1227,33 @@ def ooc_cmd_charlist(client, arg):
raise
except Exception:
client.send_ooc("File not found!")


def ooc_cmd_triple_pair(client, arg):
"""
Triple Pair with someone.
Run by itself to check your current (last?) pairing partner.
Usage: /triple_pair [cid|charname]
"""
if len(arg) == 0:
char = client.third_charid
if client.third_charid in range(0, len(client.area.area_manager.char_list)):
char = client.area.area_manager.char_list[client.third_charid]
client.send_ooc(f"Your current triple pair character is '{char}'.")
return

if arg.isdigit():
targets = client.server.client_manager.get_targets(
client, TargetType.ID, int(arg), True
)
if len(targets) > 0:
client.third_charid = targets[0].char_id
else:
for i in range(0, len(client.area.area_manager.char_list)):
if arg.lower() == client.area.area_manager.char_list[i].lower():
client.third_charid = i

char = client.third_charid
if client.third_charid in range(0, len(client.area.area_manager.char_list)):
char = client.area.area_manager.char_list[client.third_charid]
client.send_ooc(f"Successfully paired with '{char}'! Ask them to pair with you back, and show up on the same /pos for it to work.")
60 changes: 59 additions & 1 deletion server/network/aoprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def net_cmd_ms(self, args):
additive = 0
effect = ""
pair_order = 0
third_charid = -1
if self.validate_net_cmd(
args,
self.ArgType.STR, # msg_type
Expand Down Expand Up @@ -932,6 +933,7 @@ def net_cmd_ms(self, args):
self.client.pair_order = pair_order
charid_pair = self.client.charid_pair
pair_order = self.client.pair_order
third_charid = self.client.third_charid
self.client.offset_pair = offset_pair
if emote_mod not in (5, 6):
self.client.last_sprite = anim
Expand All @@ -942,14 +944,21 @@ def net_cmd_ms(self, args):
other_emote = ""
other_flip = 0
other_folder = ""
third_offset = 0
third_emote = ""
third_flip = 0
third_folder = ""

confirmed = False
if charid_pair > -1:
for target in self.client.area.clients:
if (
not confirmed
and target.char_id == self.client.charid_pair
and target.charid_pair == self.client.char_id
and (
target.charid_pair == self.client.char_id
or target.third_charid == self.client.char_id
)
and target != self.client
and target.pos == self.client.pos
):
Expand All @@ -965,6 +974,30 @@ def net_cmd_ms(self, args):
if not confirmed:
charid_pair = -1

third_confirmed = False
if third_charid > -1:
for target in self.client.area.clients:
if (
not third_confirmed
and target.char_id == self.client.third_charid
and (
target.charid_pair == self.client.char_id
or target.third_charid == self.client.char_id
)
and target != self.client
and target.pos == self.client.pos
and self.client.charid_pair != self.client.third_charid
):
third_confirmed = True
third_offset = target.offset_pair
third_emote = target.last_sprite
third_flip = target.flip
third_folder = target.claimed_folder
third_charid = "{}^{}".format(third_charid, 0)

if not third_confirmed:
third_charid = -1

ver = self.client.version.split('.')
if len(ver) >= 2:
# Client versions 2.9 or less need to get their SFX corrected due to 2.10 changes
Expand Down Expand Up @@ -1039,6 +1072,11 @@ def net_cmd_ms(self, args):
frames_sfx, # 27
add, # 28
effect, # 29
third_charid, # 30
third_folder, # 31
third_emote, # 32
third_offset, # 33
third_flip, # 33
)
a_list = ", ".join([str(a.id) for a in target_area])
if not (self.client.area in target_area):
Expand Down Expand Up @@ -1076,6 +1114,11 @@ def net_cmd_ms(self, args):
frames_sfx,
add,
effect,
third_charid,
third_folder,
third_emote,
third_offset,
third_flip,
)
self.client.send_ooc(f"Broadcasting to areas {a_list}")
except (AreaError, ValueError):
Expand Down Expand Up @@ -1197,6 +1240,11 @@ def net_cmd_ms(self, args):
frames_sfx,
additive_value,
effect,
third_charid,
third_folder,
third_emote,
third_offset,
third_flip,
)

return
Expand Down Expand Up @@ -1245,6 +1293,11 @@ def net_cmd_ms(self, args):
additive=additive,
effect=effect,
targets=whisper_clients,
third_charid=third_charid,
third_folder=third_folder,
third_emote=third_emote,
third_offset=third_offset,
third_flip=third_flip,
)
self.client.area.send_owner_ic(
self.client.area.background,
Expand Down Expand Up @@ -1279,6 +1332,11 @@ def net_cmd_ms(self, args):
frames_sfx,
additive,
effect,
third_charid,
third_folder,
third_emote,
third_offset,
third_flip,
)

# DRO client support
Expand Down

0 comments on commit b2de61b

Please sign in to comment.