Corrected some inauthenticities in the script processor

Soft queued scripts no longer remove weak scripts
Soft queued scripts now delay logout until processed
This commit is contained in:
Ceikry 2023-08-29 01:29:09 +00:00 committed by Ryan
parent 93082bc94a
commit 4276ed731d
2 changed files with 15 additions and 20 deletions

View file

@ -94,21 +94,10 @@ class ScriptProcessor(val entity: Entity) {
var strongInQueue = false
var softInQueue = false
var anyExecuted = false
for (i in 0 until queue.size) {
val script = queue[i]
if (script is QueuedScript && script.strength == QueueStrength.STRONG)
strongInQueue = true
if (script is QueuedUseWith && script.strength == QueueStrength.STRONG)
strongInQueue = true
if (script is QueuedScript && script.strength == QueueStrength.SOFT)
softInQueue = true
if (script is QueuedUseWith && script.strength == QueueStrength.SOFT)
softInQueue = true
}
strongInQueue = hasTypeInQueue(QueueStrength.STRONG)
softInQueue = hasTypeInQueue(QueueStrength.SOFT)
if (softInQueue) {
removeWeakScripts()
removeNormalScripts()
if (softInQueue || strongInQueue) {
if (entity is Player) {
entity.interfaceManager.close()
entity.interfaceManager.closeChatbox()
@ -118,11 +107,6 @@ class ScriptProcessor(val entity: Entity) {
if (strongInQueue) {
removeWeakScripts()
if (entity is Player) {
entity.interfaceManager.close()
entity.interfaceManager.closeChatbox()
entity.dialogueInterpreter.close()
}
}
val toRemove = ArrayList<Script<*>>()
@ -315,4 +299,14 @@ class ScriptProcessor(val entity: Entity) {
private fun getActiveInteraction() : Script<*>? {
return opScript ?: apScript
}
fun hasTypeInQueue (type: QueueStrength) : Boolean {
for (script in queue) {
if (script is QueuedScript && script.strength == type)
return true
else if (script is QueuedUseWith && script.strength == type)
return true
}
return false
}
}

View file

@ -12,6 +12,7 @@ import core.game.container.impl.InventoryListener;
import core.game.dialogue.DialogueInterpreter;
import core.game.interaction.InteractPlugin;
import core.game.interaction.InteractionListeners;
import core.game.interaction.QueueStrength;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState;
import core.game.node.entity.combat.CombatStyle;
@ -954,7 +955,7 @@ public class Player extends Entity {
* @return {@code True} if so.
*/
public boolean allowRemoval() {
return !(inCombat() || getSkills().getLifepoints() < 1 || DeathTask.isDead(this) || isTeleporting());
return !(inCombat() || getSkills().getLifepoints() < 1 || DeathTask.isDead(this) || isTeleporting() || scripts.hasTypeInQueue(QueueStrength.SOFT));
}
/**