From c91e9893098c0a6d1b5f72ffcce2a82e91d0e60c Mon Sep 17 00:00:00 2001
From: corncobman21 <corncobman21@hotmail.com>
Date: Wed, 18 Apr 2018 05:34:48 -0400
Subject: [PATCH] Use getSlave() and cleanup

---
 src/npc/agent/agentWorkaround.tw | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/npc/agent/agentWorkaround.tw b/src/npc/agent/agentWorkaround.tw
index 53102f94d1f..f45c7be8821 100644
--- a/src/npc/agent/agentWorkaround.tw
+++ b/src/npc/agent/agentWorkaround.tw
@@ -1,6 +1,6 @@
 :: Agent Workaround [nobr]
 
-<<set $nextButton = "Continue", $nextLink = "Neighbor Interact", _SL = $slaves.length, _ID = $slaves[$i].ID>>
+<<set $nextButton = "Continue", $nextLink = "Neighbor Interact", _ID = $slaves[$i].ID>>
 
 <<assignJob $slaves[$i] "be your agent">>
 
@@ -10,8 +10,8 @@
 <</if>>
 
 <<if $slaves[$i].rivalry > 0>>
-	<<set _i = $slaves.findIndex(function(s) { return s.rivalryTarget == _ID; })>>
-	<<if _i != -1>>
+	<<set _i = getSlave($slaves[$i].rivalryTarget)>>
+	<<if def _i>>
 		<<set $slaves[_i].rivalry = 0, $slaves[_i].rivalryTarget = 0>>
 	<<else>>
 		@@.red;Error, rival not found.@@
@@ -20,7 +20,7 @@
 <</if>>
 
 <<if $slaves[$i].relationship > 0 && $slaves[$i].relationship < 4>>
-	<<set _i = $slaves.findIndex(function(s) { return s.relationshipTarget == _ID; })>>
+	<<set _i = getSlave($slaves[$i].relationshipTarget)>>
 	<<if _i != -1>>
 		<<set $slaves[_i].relationship = 0, $slaves[_i].relationshipTarget = 0>>
 	<<else>>
-- 
GitLab