Explorar el Código

Replaced Timer logic for 3 only per team with arbitrary number

KeyMasterOfGozer hace 5 años
padre
commit
4cf5b38533
Se han modificado 1 ficheros con 57 adiciones y 69 borrados
  1. 57 69
      locations/fight.qsrc

+ 57 - 69
locations/fight.qsrc

@@ -55,6 +55,7 @@ if $ARGS[0] = 'initFight':
 	killvar 'opp_dambonus'
 	killvar 'opp_init'
 	killvar 'opp_stun'
+	killvar 'opp_timer'
 
 	!! Clear any allies from previous battle
 	i = arrsize('pcs_health')
@@ -100,6 +101,7 @@ if $ARGS[0] = 'clearPCSArray':
 	killvar 'pcs_dambonus', i
 	killvar 'pcs_init', i
 	killvar 'pcs_stun', i
+	killvar 'pcs_timer', i
 
 	killvar 'i'
 end
@@ -194,27 +196,20 @@ if $ARGS[0] = 'start':
 
 	*pl func('cleanHTML',$HTMLText)
 
-	pcs_timer[0] = 100 - pcs_react
-	if pcs_health[1] > 0:
-		pcs_timer[1] = 100 - pcs_react[1]
-	else
-		pcs_timer[1] = 100
-	end
-	if pcs_health[2] > 0:
-		pcs_timer[2] = 100 - pcs_react[2]
-	else
-		pcs_timer[2] = 100
-	end
-	opp_timer[0] = 100 - opp_react[0]
-	if opp_health[1] > 0:
-		opp_timer[1] = 100 - opp_react[1]
-	else
-		opp_timer[1] = 100
+	i=0
+	:PCSTimerInit
+	if i < arrsize('pcs_health'):
+		pcs_timer[i] = 100 - pcs_react[i]
+		i +=1
+		jump 'PCSTimerInit'
 	end
-	if opp_health[2] > 0:
-		opp_timer[2] = 100 - opp_react[2]
-	else
-		opp_timer[2] = 100
+
+	i=0
+	:OppTimerInit
+	if i < arrsize('opp_health'):
+		opp_timer[i] = 100 - opp_react[i]
+		i +=1
+		jump 'OppTimerInit'
 	end
 
 	act 'Engage': gt 'fight', 'main'
@@ -224,57 +219,50 @@ if $ARGS[0] = 'start':
 	killvar 'i'
 end
 
+if $ARGS[0] = 'findActiveTimer':
+!! Find the participant with the lowest Timer
+!	These values are passed back via two global variables.
+!
+!	$fightTimType = 'player' or 'opponent' depending on which group has the lowest member
+!	fightTimNum = the array number of the lowest participant
+
+	$fightTimType = 'player'
+	fightTimNum = 0
+	!! set this to high so that everyone will be lower.
+	fightTimLow = 99999
+
+	!! Find lowest of pcs participants
+	i = 0
+	:LowTimerLoop1
+	if i < arrsize('pcs_timer'):
+		if pcs_timer[i] < fightTimLow:
+			fightTimLow = pcs_timer[i]
+			fightTimNum = i
+		end
+		i += 1
+		jump 'LowTimerLoop1'
+	end
+
+	!!Find if any Opponents have lower than best PCS
+	i = 0
+	:LowTimerLoop2
+	if i < arrsize('opp_timer'):
+		if opp_timer[i] < fightTimLow:
+			fightTimLow = opp_timer[i]
+			fightTimNum = i
+			$fightTimType = 'opponent'
+		end
+		i += 1
+		jump 'LowTimerLoop2'
+	end
+
+	killvar 'i'
+end
+
 if $ARGS[0] = 'main':
 	gs 'fight', 'result_check'
-	if pcs_timer[0] < opp_timer[0] and pcs_timer[0] < opp_timer[1] and pcs_timer[0] < opp_timer[2] and pcs_timer[0] < pcs_timer[1] and pcs_timer[0] < pcs_timer[2]:
-		if opp_health[0] > 0: opp_timer[0] -= pcs_timer[0]
-		if opp_health[1] > 0: opp_timer[1] -= pcs_timer[0]
-		if opp_health[2] > 0: opp_timer[2] -= pcs_timer[0]
-		if pcs_health[1] > 0: pcs_timer[1] -= pcs_timer[0]
-		if pcs_health[2] > 0: pcs_timer[2] -= pcs_timer[0]
-		pcs_timer[0] = 0
-		gt 'fight', 'player', 0
-	elseif pcs_timer[1] < opp_timer[0] and pcs_timer[1] < opp_timer[1] and pcs_timer[1] < opp_timer[2] and pcs_timer[1] < pcs_timer[0] and pcs_timer[1] < pcs_timer[2]:
-		if opp_health[0] > 0: opp_timer[0] -= pcs_timer[1]
-		if opp_health[1] > 0: opp_timer[1] -= pcs_timer[1]
-		if opp_health[2] > 0: opp_timer[2] -= pcs_timer[1]
-		if pcs_health[0] > 0: pcs_timer[0] -= pcs_timer[1]
-		if pcs_health[2] > 0: pcs_timer[2] -= pcs_timer[1]
-		pcs_timer[1] = 0
-		gt 'fight', 'player', 1
-	elseif pcs_timer[2] < opp_timer[0] and pcs_timer[2] < opp_timer[1] and pcs_timer[2] < opp_timer[2] and pcs_timer[2] < pcs_timer[1] and pcs_timer[2] < pcs_timer[0]:
-		if opp_health[0] > 0: opp_timer[0] -= pcs_timer[2]
-		if opp_health[1] > 0: opp_timer[1] -= pcs_timer[2]
-		if opp_health[2] > 0: opp_timer[2] -= pcs_timer[2]
-		if pcs_health[0] > 0: pcs_timer[0] -= pcs_timer[2]
-		if pcs_health[1] > 0: pcs_timer[1] -= pcs_timer[2]
-		pcs_timer[2] = 0
-		gt 'fight', 'player', 2
-	elseif opp_timer[0] < opp_timer[1] and opp_timer[0] < opp_timer[2] and opp_timer[0] < pcs_timer[0] and opp_timer[0] < pcs_timer[1] and opp_timer[0] < pcs_timer[2]:
-		if opp_health[1] > 0: opp_timer[1] -= opp_timer[0]
-		if opp_health[2] > 0: opp_timer[2] -= opp_timer[0]
-		if pcs_health[0] > 0: pcs_timer[0] -= opp_timer[0]
-		if pcs_health[1] > 0: pcs_timer[1] -= opp_timer[0]
-		if pcs_health[2] > 0: pcs_timer[2] -= opp_timer[0]
-		opp_timer[0] = 0
-		gt 'fight', 'opponent', 0
-	elseif opp_timer[1] < opp_timer[0] and opp_timer[1] < opp_timer[2] and opp_timer[1] < pcs_timer[0] and opp_timer[1] < pcs_timer[1] and opp_timer[1] < pcs_timer[2]:
-		if opp_health[0] > 0: opp_timer[0] -= opp_timer[1]
-		if opp_health[2] > 0: opp_timer[2] -= opp_timer[1]
-		if pcs_health[0] > 0: pcs_timer[0] -= opp_timer[1]
-		if pcs_health[1] > 0: pcs_timer[1] -= opp_timer[1]
-		if pcs_health[2] > 0: pcs_timer[2] -= opp_timer[1]
-		opp_timer[1] = 0
-		gt 'fight', 'opponent', 1
-	elseif opp_timer[2] < opp_timer[0] and opp_timer[2] < opp_timer[1] and opp_timer[2] < pcs_timer[0] and opp_timer[2] < pcs_timer[1] and opp_timer[2] < pcs_timer[2]:
-		if opp_health[0] > 0: opp_timer[0] -= opp_timer[2]
-		if opp_health[1] > 0: opp_timer[1] -= opp_timer[2]
-		if pcs_health[0] > 0: pcs_timer[0] -= opp_timer[2]
-		if pcs_health[1] > 0: pcs_timer[1] -= opp_timer[2]
-		if pcs_health[2] > 0: pcs_timer[2] -= opp_timer[2]
-		opp_timer[2] = 0
-		gt 'fight', 'opponent', 2
-	end
+	gs 'fight', 'findActiveTimer'
+	gt 'fight', $fightTimType, fightTimNum
 end
 
 if $ARGS[0] = 'printStats':