mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-21 19:08:30 +01:00
Fixed issues in immunity management:
- Can detect the case where you unequip an item that grants an immunity while having another, temporary, immunity to the same actor condtion - Reapplies an AC coming from an equipped item when you unequip another item that granted immunity. - Added immunities to the saves.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package com.gpl.rpg.AndorsTrail.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.ActorConditionListeners;
|
||||
@@ -107,7 +110,8 @@ public final class ActorStatsController {
|
||||
for (ActorConditionEffect e : equipEffects.addedConditions) {
|
||||
if (!e.conditionType.conditionTypeID.equals(type.conditionTypeID)) continue;
|
||||
if (!e.isImmunity()) continue;
|
||||
// The player is wearing some other item that gives this condition. It will not be removed now.
|
||||
if (e.duration != duration) continue;
|
||||
// The player is wearing some other item that gives this immunity. It will not be removed now.
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -120,6 +124,26 @@ public final class ActorStatsController {
|
||||
actorConditionListeners.onActorConditionImmunityRemoved(player, c);
|
||||
break;
|
||||
}
|
||||
//Looking for still-equipped items that would reapply this actor condition.
|
||||
List<ActorConditionEffect> toReapply = new ArrayList<ActorConditionEffect>();
|
||||
for (Inventory.WearSlot slot : Inventory.WearSlot.values()) {
|
||||
ItemType t = player.inventory.getItemTypeInWearSlot(slot);
|
||||
if (t == null) continue;
|
||||
|
||||
ItemTraits_OnEquip equipEffects = t.effects_equip;
|
||||
if (equipEffects == null) continue;
|
||||
if (equipEffects.addedConditions == null) continue;
|
||||
for (ActorConditionEffect e : equipEffects.addedConditions) {
|
||||
if (!e.conditionType.conditionTypeID.equals(type.conditionTypeID)) continue;
|
||||
//There's another immunity (a temporary one for example) active. No nned to keep looking.
|
||||
if (e.isImmunity()) return;
|
||||
// The player is wearing some other item that gives this formerly immune actor condition
|
||||
toReapply.add(e);
|
||||
}
|
||||
}
|
||||
for (ActorConditionEffect e : toReapply) {
|
||||
applyActorCondition(player, e, ActorCondition.DURATION_FOREVER);
|
||||
}
|
||||
}
|
||||
|
||||
public void applyActorCondition(Actor actor, ActorConditionEffect e) { applyActorCondition(actor, e, e.duration); }
|
||||
|
||||
@@ -308,6 +308,13 @@ public final class Player extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
if (fileversion >= 43) {
|
||||
final int numConditions = src.readInt();
|
||||
for(int i = 0; i < numConditions; ++i) {
|
||||
this.immunities.add(new ActorCondition(src, world, fileversion));
|
||||
}
|
||||
}
|
||||
|
||||
this.lastPosition.readFromParcel(src, fileversion);
|
||||
this.nextPosition.readFromParcel(src, fileversion);
|
||||
this.level = src.readInt();
|
||||
@@ -380,6 +387,10 @@ public final class Player extends Actor {
|
||||
for (ActorCondition c : conditions) {
|
||||
c.writeToParcel(dest);
|
||||
}
|
||||
dest.writeInt(immunities.size());
|
||||
for (ActorCondition c : immunities) {
|
||||
c.writeToParcel(dest);
|
||||
}
|
||||
lastPosition.writeToParcel(dest);
|
||||
nextPosition.writeToParcel(dest);
|
||||
dest.writeInt(level);
|
||||
|
||||
Reference in New Issue
Block a user